home *** CD-ROM | disk | FTP | other *** search
-
- /*
- * %W% %G%
- */
-
- /* Copyright 1986 Eric Jul and Norm Hutchinson
- * Modifications Copyright 1988,1989 Clinton Jeffery
- * May not be used for any purpose without written permission from the authors.
- * The Emerald kernel for the Emerald programming language.
- * Version 5.4 started 1986-06-16, eric
- * Version 6.0 started 1988-07-21 cjeffery @(#)locate.c 1.7 4/5/89
- */
-
- #include <stdio.h>
-
- #include "Kernel/h/system.h"
- #include "Kernel/h/assert.h"
- #include "Kernel/h/macros.h"
- #include "Kernel/h/errMsgs.h"
- #include "Kernel/h/mmCodes.h"
- #include "Kernel/h/emTypes.h"
- #include "Kernel/h/timerTypes.h"
- #include "Kernel/h/kmdTypes.h"
- #include "Kernel/h/kEvents.h"
- #include "Kernel/h/emCodes.h"
- #include "Kernel/h/mmMsgTypes.h"
- #include "Kernel/h/lmTypes.h"
- #include "Kernel/h/emkDefs.h"
- #include "Kernel/h/lmCodes.h"
- #include "Kernel/h/hotsTypes.h"
- #include "Kernel/h/map.h"
- #include "Kernel/h/set.h"
- #include "Kernel/h/expandArray.h"
- #include "Kernel/h/consts.h"
- #include "Kernel/h/utils.h"
- #include "Kernel/h/cPLog.h"
- #include "Kernel/h/cPDBM.h"
- #include "Kernel/h/checkPoint.h"
- #include "Kernel/h/replicant.h"
- extern void unavail();
-
-
- /*
- * CHECKPOINT support is now integrated into this module-- 7/22/88 cjeffery
- *
- * Throughout the move _delivery_ subsystem, a null LMHandle
- * signifies a Checkpoint operation instead of the usual move.
- * The recovery subsystem typically uses LMHandles as replicantPtrs.
- */
- #define ISCHECKPOINT (!fHandlePtr)
- #ifdef CHECKPOINT
-
- #define GETDATA(hp,off,lena)\
- if(isRecovery){\
- CP_GetData(((replicantPtr)(hp)),(off),(lena));\
- } else {\
- LMGetData((hp),(off),(lena));\
- }
- #define PUTDATA(hp,addr,len){\
- if(ISCHECKPOINT) CP_PutData((addr),(len));\
- else LMPutData((hp),(addr),(len));}
- #define SEEKDATA(hp, val, from)\
- if(isRecovery){\
- (void)CP_Seek((hp), (val), (from));\
- } else {\
- LMSeek((hp), (val), (from));\
- }
-
- #else CHECKPOINT
-
- #define GETDATA(hp, off, lena) LMGetData((hp),(off),(lena))
- #define PUTDATA(hp,addr,len) LMPutData((hp),(addr),(len))
- #define SEEKDATA(hp, val, from) LMSeek((hp),(val),(from))
-
- #endif CHECKPOINT
-
-
-
- extern EmLocation thisNodeLocation;
- extern SSPtr removeQ(), readyQ, preemptRunning();
- extern void schedule(), fail();
- extern void insertQ();
- extern ODTag stdCodeODTag, stdGODTag;
- extern GODP thisNodeODP;
- extern GODP GetNodeODPFromLocation();
- extern AbConPtr GetAbCon(), OIDOIDOIDToAbCon();
- extern Offset IPMapLookup();
- extern HResult CheatingCrankupHandler(), StartCheatingCrankup();
- extern Boolean SSValidAddr();
- extern Boolean CheckOnDisk();
- extern Boolean IsNode();
- extern Boolean LoadRequest();
- extern OID getNextOID();
- extern SSAddr SSHighAddr();
- extern SSPtr NewStackSegment();
-
- extern void /* Snapshot */ ps();
- extern void EmallocForEach();
- extern void MoveARs(), TraverseAndMoveARList(),
- TranslateVar(), TraverseAndMove(),
- MoveSSODToTTable();
- extern int ReturnOffStack; /* Label in assembly code (!) */
-
- /* counters from measure.c */
- extern int cLOC_LocatesDone;
- extern int cLOC_ShoutsSent, cLOC_ShoutBroadcastsSent;
- extern int cLOC_SearchsSent, cLOC_SearchBroadcastsSent;
- extern int cLOC_SearchProdsSent;
-
- /* Forward */
- void
- OTDump(), OTDataDump(), LOCLocateMap(); /*snapshots*/
-
- HResult
- ShoutTimeOut(), SearchTimeOut();
- void
- StartShouting(), StartSearching(), EnsureLocationDeamon();
-
- /*
- * Declarations for AddToTTable
- * Preinitialized structures.
- * (Saves having to allocate data areas and fill in headers.)
- */
-
- TTGODEntry godEntry;
- TTCondEntry condEntry;
- TTSSODEntry ssodEntry;
- TTAbConEntry abconEntry;
- TTCEntry codeodEntry;
- TTLOEntry loEntry;
- TTMoveGODEntry movegodEntry;
- TTMoveCEntry movecodeodEntry;
- TTFetchGODEntry fetchgodEntry;
- TTCodeAddrEntry codeaddrEntry;
- TTMoveCondEntry moveCondEntry;
-
- /*
- The object table, OT, is a dynamically allocated hash table subject
- to rehashing when it gets too full.
- For starters, linear search will be used.
- */
- #define INITIALOTSIZE 4096
- #define INITIALOTMASK 4095
- ODP *OT;
- int OTSize; /* Size of OT; must be 2**n */
- int OTMask; /* must be OTSize - 1 */
- int OTLimit; /* Maximum fill before rehashing */
- int nOT; /* Current entry count in OT */
-
-
- /*
- * Locate and search data structures.
- */
- DynArray shoutList;
-
- DynArray searchList;
-
- Map LocateMap;
-
- /* Kernel return-address table */
- Map KernelReturnAddressMap, KernelReturnOpNumberMap;
-
- /* Auxilliary variables */
- LocateInfo *list;
- int listlength;
-
- Boolean LocationDeamonRunning = FALSE;
- #define LOCDEAMONINTERVAL 10000 /* microseconds */
- int vLOCDeamonInterval = LOCDEAMONINTERVAL;
- #define LOCSHOUTINTERVAL 4000000 /* microseconds */
- int vLOCShoutInterval = LOCSHOUTINTERVAL;
- #define LOCSEARCHINTERVAL 6000000 /* microseconds */
- int vLOCSearchInterval = LOCSEARCHINTERVAL;
-
-
- /************************************************************************/
-
- typedef struct TRec {
- OID theOID;
- Offset theOffset;
- } TRec, *TRecPtr;
-
- /************************************************************************/
- /* Object table */
- /************************************************************************/
-
- /* Forward */
- void OTInsert(), MoveToTTable(), AddToTTable();
- void EmDataDump();
- void EmCTRefDump();
-
- #define OThash(key) ((((key) << 1) ^ ((key) >> 24)) & OTMask)
-
- /************************************************************************/
- /* OTRehash */
- /************************************************************************/
-
- void OTRehash()
- /* This procedure doubles the size of the OT and rehashes it */
- {
- register ODP *stopAtEntry, *entry;
- ODP *theNewArray, *oldOT;
- time_t theTime = time((time_t *) 0);
-
- KMDTrace("OT", 2, "Rehashing Object Table, %d entries\n", nOT);
-
- CreateArray((int **)&theNewArray, OTSize*2*sizeof(ODP));
- stopAtEntry = &theNewArray[OTSize*2];
- for (entry = &theNewArray[0]; entry != stopAtEntry; entry++) {
- *entry = (ODP) NULL;
- }
- /* Switch tables and rehash */
- stopAtEntry = &OT[OTSize];
- OTSize += OTSize;
- OTMask = OTSize - 1;
- /* Fill no more than 87.5% */
- OTLimit = OTSize - (OTSize >> 3) - 1;
- oldOT = OT;
- nOT = 0;
- OT = theNewArray;
- for (entry = &oldOT[0]; entry !=stopAtEntry; entry++) {
- if (NonNULL((*entry))) OTInsert(*entry);
- }
- DiscardArray((int **)&oldOT);
- /* Now log a message */
- ErrMsg("%s: Doubled size of OT to %d entries, now %5.2f percent full.\n",
- ctime(&theTime), OTSize, 100.0 * ((float) nOT) / ((float) OTSize));
- }
-
- /**********************************************************************/
- /* OTLookup */
- /**********************************************************************/
-
- ODP OTLookup(fOID)
- OID fOID;
- /* Lookup the given OID in the symbol table and return the
- corresponding ODP, NULL if not found. */
- {
- register ODP *p, *tableEnd;
-
- assert(NonNULL(fOID));
-
- tableEnd = &OT[OTSize];
- p = &OT[OThash(fOID)];
- while (NonNULL(*p)) {
- if (p >= tableEnd) {
- p = & OT[0];
- }
- if ((*p)->G.ownOID == fOID) {
- KMDTrace("OT", 3, "OTLookup(0x%05x) returning 0x%05x\n", fOID,
- *p);
- return(*p);
- }
- p++;
- };
- /* Not found. */
- KMDTrace("OT", 3, "OTLookup(0x%05x) returning NULL\n", fOID);
- return( (ODP) NULL);
- }
-
- /**********************************************************************/
- /* OTInsert */
- /**********************************************************************/
-
- void OTInsert(x)
- register ODP x;
- /* Insert x into the object table */
- {
- /* Use linear search */
- register int hashIndex;
-
- if (nOT++ > OTLimit) {
- /* Rehash necessary */
- OTRehash();
- };
-
- if (IsNULL(x->G.ownOID)) {
- x->G.ownOID = getNextOID();
- }
-
- hashIndex = OThash(x->G.ownOID);
- /* Find empty entry */
- for (;OT[hashIndex]!=(ODP)NULL && OT[hashIndex]->G.ownOID != x->G.ownOID;)
- if (++hashIndex >= OTSize) hashIndex=0;
- if (NonNULL(OT[hashIndex]))
- KMDTrace("OT", 2, "OTInsert duplicate OID 0x%05x\n", x->G.ownOID);
- OT[hashIndex] = x;
- KMDTrace("OT", 3, "OTInsert[%d]:: OID 0x%05x\n", hashIndex,
- x->G.ownOID);
- }
-
-
- /**********************************************************************/
- /* OTForEach */
- /**********************************************************************/
-
- void OTForEach(f)
- int (*f)();
- /* Call f for with the address of each entry in the object table */
- {
- register int hashIndex;
-
- for (hashIndex = 0; hashIndex < OTSize; hashIndex++) {
- if (OT[hashIndex] != (ODP)NULL) {
- f(&OT[hashIndex]);
- }
- }
- }
-
- /*
- * For each object table entry that is -1, re-insert all following ones.
- */
- void OTFinishDelete()
- {
- register ODP *p, x, *tableEnd;
- register int done = 0;
-
- for (p = &OT[0], tableEnd = &OT[OTSize]; p < tableEnd && !done; p++) {
- if (*p == (ODP) -1) {
- *p = NULL;
- KMDTrace("OT", 3, "OTDelete[%d]\n", p-&OT[0]);
- if (++p >= tableEnd) { p = &OT[0]; done = 1; }
- while (NonNULL(*p)) {
- x = *p;
- *p = NULL;
- if (x != (ODP)-1) OTInsert(x);
- p++;
- if (p >= tableEnd) { p = &OT[0]; done = 1; }
- }
- }
- }
- }
-
- /*
- * getFreeOD
- *
- * Gets a free entry in the object table
- */
- ODP getFreeOD()
- {
- return ( (ODP) emallocnil(sizeof(OD)) );
- }
-
-
-
- /*
- * CreateUnknownGODEntry
- */
- GODP CreateUnknownGODEntry(fOID)
- OID fOID;
- {
- GODP p = (GODP) getFreeOD();
-
- p->ownOID = fOID;
- p->ownLoc = (EmLocation) NULL;
- p->tag = stdGODTag;
- p->tag.frozen = TRUE;
- p->tag.isResident = FALSE;
- p->dataPtr = (GODataPtr) NULL;
- OTInsert((ODP) p);
- return p;
- }
-
-
-
- /*
- * CreateGODEntry
- */
- GODP CreateGODEntry(fOID, fCodeOID)
- OID fOID, fCodeOID;
- {
- GODP p = (GODP) getFreeOD();
- KMDTrace("TT", 3, "CreateGODEntry(0x%05x, 0x%05x)\n", fOID, fCodeOID);
- p->ownOID = fOID;
- p->ownLoc = (EmLocation) NULL;
- p->tag = stdGODTag;
- p->tag.frozen = TRUE;
- p->tag.isResident = FALSE;
- p->dataPtr = (GODataPtr) NULL;
- p->myCodeOID = fCodeOID;
- p->ARListHead.next = p->ARListHead.prev = (InvokeQueuePtr) &p->ARListHead;
- OTInsert((ODP) p);
- return p;
- }
-
-
-
- /*
- * CreateCodeODEntry
- *
- * If necessary, create an OD for remote code
- */
- CodeODP CreateCodeODEntry(fCodeOID, fLocation)
- OID fCodeOID;
- EmLocation fLocation;
- {
- register CodeODP p;
-
- if (NonNULL(p = (CodeODP) OTLookup(fCodeOID))) { /* We already know it */
- return p;
- }
- KMDTrace("Code",3, "CreateCodeODEntry(0x%05x, 0x%05x)\n",fCodeOID,fLocation);
-
- p = (CodeODP) emalloc(sizeof(CodeOD));
- p->ownOID = fCodeOID;
- p->ownLoc = fLocation;
- p->tag = stdCodeODTag;
- p->tag.frozen = TRUE;
- p->tag.isResident = FALSE;
- p->tag.setUpDone = FALSE;
- p->dataPtr = (CodePtr) NULL;
- p->AbConSetPtr = (GenericPtr) Set_Create();
- p->depCode = (GenericPtr) NULL;
- OTInsert((ODP) p);
- return p;
- }
-
- /************************************************************************/
- /************************************************************************/
- /* Location algorithm */
- /************************************************************************/
- /************************************************************************/
-
- /************************************************************************/
-
- void RemoveFromSearchLists(fReq)
- LocateReqPtr fReq;
- {
- register int i, count;
- register OID *p;
-
- KMDTrace("Locate", 3, "Remove from search lists\n");
-
- if (fReq->status == Shouting) { /* Remove from Shout list */
- count = DynCount(shoutList);
- p = (OID *) &shoutList->array[count-1];
- for (i = count - 1; i >= 0; i--, p--) {
- if (*p == fReq->theOID) DynRemove(shoutList, i);
- }
- }
- if (fReq->status == Searching) { /* Remove from search list */
- count = DynCount(searchList);
- p = (OID *) &searchList->array[count-1];
- for (i = count - 1; i >= 0; i--, p--) {
- if (*p == fReq->theOID) DynRemove(searchList, i);
- }
- }
- }
- /************************************************************************/
- /* call back */
- HResult FoundIt(fReq, fOID)
- register LocateReqPtr fReq;
- register OID fOID;
- {
- register ODP theODP = (ODP) OTLookup(fOID);
- assert(NonNULL(theODP));
- KMDTrace("Locate", 3, "%s found at 0x%04x\n", PPOID(fOID), theODP->G.ownLoc);
- if (fReq->status == Shouting || fReq->status == Searching) {
- RemoveFromSearchLists(fReq);
- }
- Map_Delete(LocateMap, (int) fOID);
- if (fReq->waiting) {
- fReq->waiting->resultBrand = ODPBrand;
- fReq->waiting->regs.arg1 =
- (int) GetNodeODPFromLocation(theODP->G.ownLoc);
- schedule(fReq->waiting);
- fReq->waiting = (SSPtr) NULL;
- }
- DoCallBack((GenericReqPtr) fReq, fOID);
- FreeRequest((GenericReqPtr) fReq);
- }
-
-
-
- /*
- * CouldNotFindIt
- *
- * The location algorithm has given up. Report back
- */
- void CouldNotFindIt(fReq)
- register LocateReqPtr fReq;
- {
- register ODP theODP = (ODP) OTLookup(fReq->theOID);
- extern HResult RecoverItemHandler();
- assert(NonNULL(theODP));
- KMDTrace("Locate", 3, "%s not found: 0x%04x\n", PPOID(fReq->theOID),
- theODP->G.ownLoc);
-
- #ifdef CHECKPOINT
- /* Inserted logic to recover using a local replicant here */
- if(theODP->G.tag.tag == GODTag && theODP->G.Replicant != (char *)EMNIL) {
- KMDTrace("Recover",3,"%s not found, but we have a replicant at 0x%04x\n",
- PPOID(fReq->theOID),theODP->G.ownLoc);
- RecoverItemHandler(((replicantPtr)(theODP->G.Replicant)),theODP);
- FoundIt(fReq, fReq->theOID);
- return;
- }
- #endif
-
- if (fReq->status == Shouting || fReq->status == Searching) {
- RemoveFromSearchLists(fReq);
- }
- Map_Delete(LocateMap, (int) fReq->theOID);
- theODP->G.ownLoc = (EmLocation) NULL;
- if (NonNULL(fReq->waiting)) {
- fReq->waiting->resultBrand = VariableBrand;
- fReq->waiting->regs.arg1 = (int) EMNIL;
- fReq->waiting->regs.arg2 = (int) EMNIL;
- schedule(fReq->waiting);
- fReq->waiting = (SSPtr) NULL;
- }
- DoCallBack((GenericReqPtr) fReq, fReq->theOID);
- FreeRequest((GenericReqPtr) fReq);
- }
-
-
-
- /*
- * StartConfirming
- */
- void StartConfirming(fReq)
- register LocateReqPtr fReq;
- {
- LocateItem l;
- LMHandle myHandle;
- HOTSRecordPtr HOTS;
- NodeNum lnn;
-
- lnn = mGetLocNodeNum(fReq->theLocation);
- if (IsNULL(lnn) || !mSUCCESS(HOTSSearchPtr(lnn, &HOTS)) ||
- HOTS->NodeStat != Alive) {
- /* The node is not considered alive, move along to shouting */
- KMDTrace("Locate", 3, "0x%08x on unknown or down node %d\n",
- fReq->theOID, lnn);
- StartShouting(fReq);
- return;
- }
- fReq->status = Confirming;
- KMDTrace("Locate", 3, "Start confirmation for 0x%05x @ 0x%05x\n",
- fReq->theOID, fReq->theLocation);
-
- l.hdr.itemTag = ConfirmITag;
- l.hdr.size = sizeof(l);
- l.obj[0].theOID = fReq->theOID;
- l.obj[0].theLocation= fReq->theLocation;
- LMStartMsg(&myHandle, KMSG_EmKernel, EMKM_Item, lnn);
- LMPutData(&myHandle, &l, sizeof(l));
- LMSendMsg(&myHandle);
- }
-
-
-
- /*
- * StartShouting
- */
- void StartShouting(fReq)
- register LocateReqPtr fReq;
- {
- Boolean result;
-
- KMDTrace("Locate", 3, "StartShouting for OID 0x%05x\n", fReq->theOID);
- if ((((unsigned int) fReq->theOID >> 24) & 0xFF) == 0xFF) {
- /* Check on own disk first */
- if (CheckOnDisk(fReq->theOID)) {
- KMDTrace("Locate", 3, "Found %s on disk.\n", PPOID(fReq->theOID));
- fReq->status = WaitingForCodeLoad;
- fReq->hdr.callBack = (GenericHandlerPtr) FoundIt;
- result = LoadRequest(fReq->theOID, (GenericReqPtr) fReq);
- if (result && NonNULL(OTLookup(fReq->theOID))) {
- KMDTrace("Locate", 4, "Got %s loaded.\n", PPCOID(fReq->theOID));
- /* Now do the up call */
- FoundIt(fReq, fReq->theOID);
- return;
- }
- if (NonNULL(OTLookup(fReq->theOID))) {
- KMDTrace("FixMe", 3, "obj was compiler created ???\n");
- KMDTrace("Locate", 4, "Did not get it all loaded; waiting\n");
- return;
- }
- }
- KMDTrace("Locate", 4, "Did not find it on disk; now shouting.\n");
- }
-
- fReq->status = Shouting;
- /* Enter into shoutList */
- DynAddUpper(shoutList, (int) fReq->theOID);
- EnsureLocationDeamon();
- (void) MMSetMicroTimer((int)(vLOCShoutInterval/1000000),
- (int)(vLOCShoutInterval%1000000), (HandlerPtr)ShoutTimeOut,
- (int)fReq->theOID, (TimerId *)&fReq->timerId);
- }
-
-
-
- /*
- * StartSearching
- */
- void StartSearching(fReq)
- LocateReqPtr fReq;
- {
- register unsigned char *first;
- register LocateReqPtr req = fReq;
- register GODP theObj;
- extern HResult StartCheatingCrankup();
-
- req->status = Searching;
- first = &req->replyList[0];
- bzero((char *)first,&req->replyList[MAXNODENUMBER]-first);
-
- KMDTrace("Locate", 3, "Start Searching for OID 0x%05x\n", req->theOID);
- if ((req->theOID >> 24 & 0xFF) == 0xFE) {
- /* It was created by the compiler so look on disk */
- KMDTrace("Locate", 4, "Trying on disk\n");
- if (CheckOnDisk(req->theOID)) {
- KMDTrace("Locate", 3, "Found on disk, crank it up\n");
- /* Create a GOD entry for it */
- if (IsNULL(OTLookup(req->theOID))) {
- theObj = CreateGODEntry(req->theOID, (OID) NULL);
- theObj->ownLoc = thisNodeLocation;
- theObj->tag.isResident = TRUE;
- theObj->tag.setUpDone = FALSE;
- KMDTrace("Create", 3, "GOD for Cheating object %s\n",
- PPGOID(req->theOID));
- }
- req->status = WaitingForCodeLoad;
- StartCheatingCrankup(req->theOID, (GenericReqPtr) req);
- return;
- }
- }
-
- /* Enter into search list */
- DynAddUpper(searchList, (int) fReq->theOID);
- EnsureLocationDeamon();
- (void)MMSetMicroTimer((int)(vLOCSearchInterval/1000000),
- (int)(vLOCSearchInterval%1000000), (HandlerPtr)SearchTimeOut,
- (int)fReq->theOID, (TimerId *)&fReq->timerId);
- }
-
-
-
-
- /*
- * RedoConfirm
- */
- void RedoConfirm(fReq)
- LocateReqPtr fReq;
- {
- KMDTrace("Locate", 3, "RedoConfirm for OID 0x%05x\n", fReq->theOID);
- StartConfirming(fReq);
- }
-
-
-
- /*
- * SendLocationProd
- */
- void SendLocationProd(fLNN, fOID)
- NodeNum fLNN;
- OID fOID;
- {
- LMHandle myHandle;
- LocateItem item;
-
- KMDTrace("Locate", 3, "Sending prod for %s to node #%d\n", PPOID(fOID),fLNN);
- LMStartMsg(&myHandle, KMSG_EmKernel, EMKM_Item, fLNN);
- item.hdr.itemTag = SearchITag;
- item.hdr.size = sizeof(item);
- item.obj[0].theOID = fOID;
- item.obj[0].theLocation = (EmLocation) NULL;
- LMPutData(&myHandle, &item, sizeof(item));
- cLOC_SearchProdsSent++;
- (void) LMSendMsg(&myHandle);
- }
-
-
-
- void GoThroughReplyListToSeeIfEveryoneHasReplied(fReq, sendProd)
- LocateReqPtr fReq;
- Boolean sendProd;
- {
- register int i;
- register struct HOTStr *np;
- int prodCount;
- KMDTrace("Locate", 4, "Checking for search completion for %s\n",
- PPOID(fReq->theOID));
- /* Traverse HOTS table and create list of entries */
- prodCount = 0;
- for (i=0; i < HOTSIZE; i++) {
- for(np = HOTSTable[i]; np != NULL; np = np -> next) {
- if (np->ThisEntry.NodeStat == Alive &&
- (np->ThisEntry.LNN != GetLNN()) &&
- ! (Boolean) fReq->replyList[np->ThisEntry.LNN]) {
- if(sendProd)SendLocationProd(np->ThisEntry.LNN, fReq->theOID);
- prodCount++;
- }
- }
- }
- if(sendProd)KMDTrace("Locate", 3, "Prodded %d nodes.\n", prodCount);
- if (prodCount == 0) {
- KMDTrace("Locate", 3, "Search result: Cannot find object %s\n",
- PPOID(fReq->theOID));
- CouldNotFindIt(fReq);
- } else {
- KMDTrace("Locate", 4, "Search not done yet.\n");
- if(sendProd)KMDTrace("Locate", 4, " (prodded %d nodes)\n",prodCount);
- }
- }
-
-
- void CheckForSearchDone(fReq)
- LocateReqPtr fReq;
- {
- GoThroughReplyListToSeeIfEveryoneHasReplied(fReq, False);
- }
-
-
-
- void CheckForProd(fReq)
- LocateReqPtr fReq;
- {
- GoThroughReplyListToSeeIfEveryoneHasReplied(fReq, True);
- }
-
- /************************************************************************/
- /************************************************************************/
-
- /************************************************************************/
- /* NewLocation */
- /************************************************************************/
- EmLocation NewLocation(fOldLocation, fNewLNN)
- EmLocation fOldLocation;
- NodeNum fNewLNN;
- {
- return mMakeLocation(fNewLNN, mGetLocTimeStamp(fOldLocation)+1);
- }
-
-
-
-
- /*
- * UpdateLocation
- *
- * Update the OT with new location information
- */
- void UpdateLocation(fOID, fNewLocation, fInfoSrc)
- OID fOID;
- EmLocation fNewLocation;
- NodeNum fInfoSrc;
- {
- register ODP theODP;
- register LocateReqPtr req;
- EmLocation oldLocation;
- NodeNum nodeLNN;
- Boolean gotNewLoc;
-
- theODP = OTLookup(fOID);
- if (IsNULL(theODP)) {
- KMDTrace("Locate", 2, "Unknown object (0x%04x) -- ignored\n",fOID);
- return;
- }
-
- /* Check to see if location timestamp is newer */
- oldLocation = theODP->G.ownLoc;
- gotNewLoc= mGetLocTimeStamp(oldLocation) < mGetLocTimeStamp(fNewLocation);
-
- if (gotNewLoc) {
- KMDTrace("Locate", 3,
- "OID 0x%05x was @ 0x%04x now @ 0x%04x; source: node #%d\n",
- theODP->G.ownOID, theODP->G.ownLoc, fNewLocation, fInfoSrc);
- theODP->G.ownLoc = fNewLocation;
- KMDTrace("FixMe", 3, "Fix me: should reset ODTag flags.\n");
- }
-
- /* Check outstanding requests */
-
- req = (LocateReqPtr) Map_Lookup(LocateMap, (int) fOID);
- if (IsNIL(req)) return;
-
- nodeLNN = mGetLocNodeNum(fNewLocation);
- req->replyList[fInfoSrc] = (unsigned char) TRUE;
- if (gotNewLoc) {
- req->theLocation = fNewLocation;
- }
-
- /* We have found a request for the object */
- switch (req->status) {
-
- case Waiting:
- case WaitingForCodeLoad:
- /* ignore */
- break;
-
- case Confirming:
- if (mGetLocNodeNum(oldLocation) == fInfoSrc) {
- /* It is the guy we were requesting a confirmation from */
-
- if (nodeLNN == fInfoSrc) {
- HEHASIT:
- KMDTrace("Locate",3, "OID 0x%05x found @ 0x%05x\n", fOID,fNewLocation);
- FoundIt(req, fOID);
- } else /* He is giving us a new location */
- if (gotNewLoc) {
- REDO:
- KMDTrace("Locate", 3, "Redoing confirm\n");
- RedoConfirm(req);
- } else {
- KMDTrace("Locate", 3, "OID 0x%05x negative confirmation from %d\n",
- fOID, fInfoSrc);
- StartShouting(req);
- }
- return;
- }
- if (gotNewLoc) RedoConfirm(req);
- return;
-
- case Shouting:
- if (gotNewLoc) {
- GOTNEWLOC:
- if (nodeLNN==fInfoSrc) goto HEHASIT;
- else goto REDO;
- }
- return;
-
- case Searching:
- if (gotNewLoc) goto GOTNEWLOC;
- else {
- req->replyList[fInfoSrc] = TRUE;
- CheckForSearchDone(req);
- }
- }
- }
-
-
-
- /*
- * Callback routine for locate requests
- */
- HResult LocatePrevDone(fReq, fOID)
- register LocateReqPtr fReq;
- OID fOID;
- {
- LocateReqPtr oldReq;
- oldReq = (LocateReqPtr) Map_Lookup(LocateMap, (int) fOID);
-
- if (oldReq != (LocateReqPtr) EMNIL) {
- /* A location request already exists */
- Map_Insert(oldReq->hdr.reqBy, (int) fReq, 0);
- Map_Insert(fReq->hdr.wantList, (int) oldReq, 0);
- fReq->hdr.callBack = (GenericHandlerPtr) LocatePrevDone;
- KMDTrace("Locate", 3,
- "Awaiting location of 0x%05x @ 0x%05x; in %s\n", fReq->theOID,
- fReq->theLocation, PPSSPlace(fReq->waiting));
- return;
- }
- Map_Insert(LocateMap, (int) fOID, (int) fReq);
- fReq->hdr.callBack = (GenericHandlerPtr) NULL;
- KMDTrace("Locate", 3, "Locate reconfirming for 0x%05x @ 0x%02x\n",
- fReq->theOID, fReq->theLocation);
- StartConfirming(fReq);
- }
-
-
-
- /*
- * Kernel call to locate objects
- */
- void Locate(fODP, fAbConPtr)
- register ODP fODP;
- register AbConPtr fAbConPtr;
- {
- register LocateReqPtr req, oldReq;
-
- if (fAbConPtr == (AbConPtr) EMNIL || fODP == (ODP) EMNIL) {
- KMDTrace("Locate", 3, "Location of NIL causes failure\n");
- KMDTrace("Failure", 3, "locate of NIL causes failure\n");
- fail(preemptRunning());
- } else if (fAbConPtr->tag.allInstancesAreLocal) {
- KMDTrace("Locate", 3, "Location of local object returns own node.\n");
- currentSSP->resultBrand = ODPBrand;
- currentSSP->regs.arg1 = (int) thisNodeODP;
- } else if (((fODP->G.tag.tag == GODTag) && !fODP->G.tag.global)
- || (fODP->G.tag.isResident)) {
- KMDTrace("Locate", 3, "Location of resident object returns own node.\n");
- currentSSP->resultBrand = ODPBrand;
- currentSSP->regs.arg1 = (int) thisNodeODP;
- } else if (IsNode(fODP)) {
- KMDTrace("Locate", 3, "Location of node returns the node.\n");
- currentSSP->resultBrand = ODPBrand;
- currentSSP->regs.arg1 = (int) fODP;
- } else {
- /* It is a non-resident object; crank up location protocol */
- cLOC_LocatesDone++;
- req = mNewRequest(Locate);
- currentSSP->invokePtr = (GenericPtr) req;
- req->status = Confirming;
- req->theOID = fODP->G.ownOID;
- req->theLocation = fODP->G.ownLoc;
- oldReq = (LocateReqPtr) Map_Lookup(LocateMap, (int) fODP->G.ownOID);
- if (oldReq != (LocateReqPtr) EMNIL) {
- /* A location request already exists */
- Map_Insert(oldReq->hdr.reqBy, (int) req, 0);
- Map_Insert(req->hdr.wantList, (int) oldReq, 0);
- req->hdr.callBack = (GenericHandlerPtr) LocatePrevDone;
- req->waiting = preemptRunning();
- req->waiting->status.rs = SSLocateWait;
- KMDTrace("LineNumber", 4, "%s waiting for locate to complete in %s\n",
- PPPOID(req->waiting->processOID), PPSSPlace(req->waiting));
- KMDTrace("Locate", 3,"Awaiting location of 0x%05x @ 0x%05x; in %s\n",
- req->theOID, req->theLocation, PPSSPlace(req->waiting));
- return;
- }
- Map_Insert(LocateMap, (int) req->theOID, (int) req);
- req->hdr.callBack = (GenericHandlerPtr) FoundIt;
- req->waiting = preemptRunning();
- req->waiting->status.rs = SSLocateWait;
- KMDTrace("LineNumber", 4, "%s waiting for locate to complete in %s\n",
- PPPOID(req->waiting->processOID), PPSSPlace(req->waiting));
-
- KMDTrace("Locate", 3,
- "Locate startup for 0x%05x @ 0x%05x; in %s\n", req->theOID,
- req->theLocation, PPSSPlace(req->waiting));
- StartConfirming(req);
- }
- }
-
-
-
- /*
- * StartLocate
- */
- void StartLocate(fReq, fODP)
- GenericReqPtr fReq;
- ODP fODP;
- {
- register LocateReqPtr req, oldReq;
-
- KMDTrace("Locate", 3, "StartLocate for %s\n", PPOID(fODP->G.ownOID));
- cLOC_LocatesDone++;
-
- req = mNewRequest(Locate);
- Map_Insert(fReq->hdr.wantList, (int) req, 0);
- Map_Insert(req->hdr.reqBy, (int) fReq, 0);
- req->status = Confirming;
- req->theOID = fODP->G.ownOID;
- req->theLocation = fODP->G.ownLoc;
- req->waiting = (SSPtr) NULL;
- oldReq = (LocateReqPtr) Map_Lookup(LocateMap, (int) fODP->G.ownOID);
-
- if (oldReq != (LocateReqPtr) EMNIL) {
- /* A location request already exists */
- Map_Insert(oldReq->hdr.reqBy, (int) req, 0);
- Map_Insert(req->hdr.wantList, (int) oldReq, 0);
- req->hdr.callBack = (GenericHandlerPtr) LocatePrevDone;
- KMDTrace("Locate", 3, "Awaiting location of 0x%05x @ 0x%05x; in %s\n",
- req->theOID, req->theLocation, PPSSPlace(req->waiting));
- return;
- }
- Map_Insert(LocateMap, (int) req->theOID, (int) req);
- req->hdr.callBack = (GenericHandlerPtr) FoundIt;
-
- KMDTrace("Locate", 3, "Locate startup for 0x%05x @ 0x%02x\n",
- req->theOID, req->theLocation);
- StartConfirming(req);
- }
-
- /*
- * UnpackLocateItem - returns count of contents
- */
- int UnpackLocateItem(fHandlePtr,fHdr)
- LMHandlePtr fHandlePtr;
- ItemHdr fHdr;
- {
- register int length = fHdr.size - sizeof(fHdr);
- int size = length;
- while (length > listlength) {
- ExpandArray((int **)&list, listlength, listlength*2);
- listlength += listlength;
- }
- LMGetData(fHandlePtr, list, &size);
- assert(length == size);
- return length / sizeof(LocateInfo);
- }
-
- /*
- * SendLocateReply
- */
- void SendLocateReply(fHandlePtr, fHdr, tag)
- LMHandlePtr fHandlePtr;
- ItemHdr fHdr;
- ITag tag;
- {
- LMHandle replyHandle;
- LMStartMsg(&replyHandle, KMSG_EmKernel, EMKM_Item,
- (*fHandlePtr)->mmMsgHdr.MsgSrc);
- fHdr.itemTag = tag;
- LMPutData(&replyHandle, &fHdr, sizeof(fHdr));
- LMPutData(&replyHandle, list, (int)(fHdr.size - sizeof(fHdr)));
- LMSendMsg(&replyHandle);
- }
-
- /*
- * ConfirmItemHandler
- */
- HResult ConfirmItemHandler(fHandlePtr, fHdr)
- LMHandlePtr fHandlePtr;
- ItemHdr fHdr;
- {
- int count, i;
- register ODP theODP;
-
- KMDTrace("Locate", 3, "Confirm Item from node %d\n",
- (*fHandlePtr)->mmMsgHdr.MsgSrc);
-
- count = UnpackLocateItem(fHandlePtr, fHdr);
- for (i = 0; i < count; i++) {
- KMDTrace("Locate", 4, "Confirm OID 0x%05x @ 0x%05x\n",
- list[i].theOID, list[i].theLocation);
- theODP = OTLookup(list[i].theOID);
- if (IsNULL(theODP)) {
- KMDTrace("Locate", 4, "Negative confirmation of OID 0x%05x\n",
- list[i].theOID);
- list[i].theLocation = (EmLocation) NULL;
- } else {
- KMDTrace("FixMe", 5, "Fix me: need to confirm move\n");
- KMDTrace("Locate", 4, "Confirm reply for OID 0x%05x: @ 0x%05x\n",
- theODP->G.ownOID, theODP->G.ownLoc);
- list[i].theLocation = theODP->G.ownLoc;
- }
- }
- SendLocateReply(fHandlePtr, fHdr, ConfirmReplyITag);
- }
-
-
-
- /*
- * ShoutItemHandler
- */
- HResult ShoutItemHandler(fHandlePtr, fHdr)
- LMHandlePtr fHandlePtr;
- ItemHdr fHdr;
- {
- int count, i, j;
- register ODP theODP;
-
- KMDTrace("Locate",3, "Shout item from %d\n", (*fHandlePtr)->mmMsgHdr.MsgSrc);
-
- count = UnpackLocateItem(fHandlePtr,fHdr);
- j = 0; /* Note, the same list is used for replying */
- for (i = 0; i < count; i++) {
- KMDTrace("Locate", 4, "Shout was for OID 0x%05x @ 0x%05x\n",
- list[i].theOID, list[i].theLocation);
- theODP = OTLookup(list[i].theOID);
- if (IsNULL(theODP) ||
- (mGetLocNodeNum(theODP->G.ownLoc) != (unsigned int) GetLNN())) {
- if ((((unsigned int) list[i].theOID >> 24) & 0xFF) == 0xFF) {
- /* Check on own disk */
- if (CheckOnDisk(list[i].theOID)) {
- KMDTrace("Locate", 3, "Found %s on disk.\n",
- PPOID(list[i].theOID));
- list[j].theLocation = thisNodeLocation;
- list[j].theOID = list[i].theOID;
- j++;
- continue;
- }
- }
- /* Do not know it, not even in the compiler directory */
- KMDTrace("Locate", 4, "Negative confirmation for OID 0x%05x\n",
- list[i].theOID);
- } else {
- /* Put in our own location information */
- KMDTrace("FixMe", 3, "Fix me: need to confirm move\n");
- list[j].theLocation = theODP->G.ownLoc;
- list[j].theOID = theODP->G.ownOID;
- KMDTrace("Locate", 4, "Shout reply for OID 0x%05x: @ 0x%05x\n",
- theODP->G.ownOID, theODP->G.ownLoc);
- j++;
- }
- }
-
- if (j == 0) {
- /* None found here */
- KMDTrace("Locate", 4, "No OIDs found so no reply\n");
- return;
- }
-
- fHdr.size = sizeof(fHdr) + j*sizeof(list[0]);
- SendLocateReply(fHandlePtr, fHdr, ShoutReplyITag);
- }
-
-
-
- /*
- * SearchItemHandler
- */
- HResult SearchItemHandler(fHandlePtr, fHdr)
- LMHandlePtr fHandlePtr;
- ItemHdr fHdr;
- {
- int count, i;
- register OID theOID;
- register ODP theODP;
- register GODP theObj;
-
- KMDTrace("Locate",3, "Search Item from %d\n",(*fHandlePtr)->mmMsgHdr.MsgSrc);
-
- count = UnpackLocateItem(fHandlePtr,fHdr);
- for (i = 0; i < count; i++) {
- KMDTrace("Locate", 4, "Search OID 0x%05x @ 0x%05x\n", list[i].theOID,
- list[i].theLocation);
- theOID = list[i].theOID;
- theODP = OTLookup(theOID);
- if (IsNULL(theODP)) {
- if ((((unsigned int) list[i].theOID >> 24) & 0xFF) == 0xFF) {
- /* Check on own disk */
- if (CheckOnDisk(list[i].theOID)) {
- KMDTrace("Locate", 3, "Found %s on disk.\n",
- PPOID(list[i].theOID));
- list[i].theLocation = thisNodeLocation;
- list[i].theOID = list[i].theOID;
- continue;
- }
- } else if (((theOID >> 24) & 0xFF) == 0xFE) {
- KMDTrace("Locate", 4, "Trying on disk\n");
- if (CheckOnDisk(theOID)) {
- KMDTrace("Locate", 3,
- "Found on disk, scheduling crank up of it\n");
- /* Create a GOD entry for it */
- theObj = CreateGODEntry(theOID, (OID) NULL);
- theObj->ownLoc = thisNodeLocation;
- theObj->tag.isResident = TRUE;
- theObj->tag.setUpDone = FALSE;
- KMDTrace("Create", 3, "GOD for Cheating object %s\n",PPGOID(theOID));
- HoldSigs();
- QueueTask((HandlerPtr)CheatingCrankupHandler, (char *)theOID);
- ReleaseSigs();
- list[i].theLocation = thisNodeLocation;
- continue;
- }
- }
- KMDTrace("Locate", 4, "Negative search reply for OID 0x%05x\n",
- list[i].theOID);
- list[i].theLocation = (EmLocation) NULL;
- } else {
- /* Put in our own location information */
- KMDTrace("FixMe", 3, "Fix me: need to confirm move\n");
- list[i].theLocation = theODP->G.ownLoc;
- KMDTrace("Locate", 4, "Search reply for OID 0x%05x: @ 0x%05x\n",
- theODP->G.ownOID, theODP->G.ownLoc);
- }
- }
- SendLocateReply(fHandlePtr, fHdr, SearchReplyITag);
- }
-
-
- /*
- * ConfirmReplyItemHandler
- */
- HResult ConfirmReplyItemHandler(fHandlePtr, fHdr)
- LMHandlePtr fHandlePtr;
- ItemHdr fHdr;
- {
- int count, i;
- short int msgSrc;
-
- msgSrc = (*fHandlePtr)->mmMsgHdr.MsgSrc;
- KMDTrace("Locate", 3, "Confirm Reply Item from %d\n", msgSrc);
-
- count = UnpackLocateItem(fHandlePtr,fHdr);
- for (i = 0; i < count; i++) {
- KMDTrace("Locate", 4, "Confirm OID 0x%05x @ 0x%05x\n", list[i].theOID,
- list[i].theLocation);
- UpdateLocation(list[i].theOID, list[i].theLocation, msgSrc);
- }
- }
-
-
- /*
- * ShoutReplyItemHandler
- */
- HResult ShoutReplyItemHandler(fHandlePtr, fHdr)
- LMHandlePtr fHandlePtr;
- ItemHdr fHdr;
- {
- short int msgSrc;
-
- msgSrc = (*fHandlePtr)->mmMsgHdr.MsgSrc;
- KMDTrace("Locate", 3, "Shout Reply Item from %d\n",msgSrc);
- ConfirmReplyItemHandler(fHandlePtr, fHdr);
- }
-
-
- /*
- * SearchReplyItemHandler
- */
- HResult SearchReplyItemHandler(fHandlePtr, fHdr)
- LMHandlePtr fHandlePtr;
- ItemHdr fHdr;
- {
- short int msgSrc;
-
- msgSrc = (*fHandlePtr)->mmMsgHdr.MsgSrc;
- KMDTrace("Locate", 3, "Search Reply Item from %d\n", msgSrc);
- ConfirmReplyItemHandler(fHandlePtr, fHdr);
- }
-
- /************************************************************************/
- /************************************************************************/
- /*
- * AddReqToTTable
- *
- * Add the necessary information to the LMMsg given for sending the given
- * Request across the network. Enter the Req in the Sent Map.
- */
- void AddReqToTTable(fHandlePtr, fReq, fSentMap, fARSet)
- LMHandle *fHandlePtr;
- GenericPtr fReq;
- Map fSentMap;
- Set fARSet;
- {
- TTableEntry entry;
- ReqHdr hdr;
-
- hdr = ((GenericReqPtr) fReq)->hdr;
-
- KMDTrace("TT", 5, "TT: Request RTag: %s\n", PPRTag(hdr.rTag));
-
- switch (hdr.rTag) {
-
- case InvokeRTag: {
- register TTInvokeReqEntry *tReq = (TTInvokeReqEntry *) &entry;
- register InvokeReqPtr req = (InvokeReqPtr) fReq;
-
- tReq->hdr.itemTag = TTInvokeITag;
- tReq->hdr.size = sizeof(TTInvokeReqEntry);
- tReq->oldODP = (ODP) fReq;
- tReq->callerSSOID = req->i.callerSSOID;
- tReq->callerLoc = req->i.callerLoc;
- tReq->argumentCount = req->i.argumentCount;
- tReq->resultCount = req->i.resultCount;
- tReq->processOID = req->i.processOID;
- tReq->targetOID = req->i.targetOID;
- tReq->targetTryAtLoc = req->i.targetTryAtLoc;
- Map_Insert(fSentMap, (int) req, (int) RefSent);
- AddToTTable(fHandlePtr, (ODP) req->targetGODP, fSentMap, fARSet);
- break;
- }
- case IncomingIRTag: {
- register TTIncomingIReqEntry *tReq = (TTIncomingIReqEntry *) &entry;
- register IncomingIReqPtr req = (IncomingIReqPtr) fReq;
-
- tReq->hdr.itemTag = TTIncomingIITag;
- tReq->hdr.size = sizeof(TTIncomingIReqEntry);
- tReq->oldODP = (ODP) fReq;
- tReq->callerSSOID = req->i.callerSSOID;
- tReq->callerLoc = req->i.callerLoc;
- tReq->argumentCount = req->i.argumentCount;
- tReq->resultCount = req->i.resultCount;
- tReq->processOID = req->i.processOID;
- tReq->targetOID = req->i.targetOID;
- tReq->targetTryAtLoc = req->i.targetTryAtLoc;
-
- KMDTrace("FixMe", 3, "AddReqToTTable should respect visitors!!\n");
- if (NonNULL(req->visitorSet)) Set_Destroy(req->visitorSet);
-
- AddToTTable(fHandlePtr, OTLookup(req->i.callerSSOID), fSentMap, fARSet);
- break;
- }
- case LocateRTag:
- case MoveRTag:
- case StackBreakRTag:
- case CompilerLoadRTag:
- case CodeLoadRTag:
- case CheatingLoadRTag:
- case InitiallyRTag:
- case ConformRTag:
- case ViewRTag:
- case IncomingMoveRTag:
- break;
- default:
- ErrMsg("Bad RTag %s in AddReqToTTable\n", PPRTag(hdr.rTag));
- abort();
- }
- LMPutData(fHandlePtr, &entry, entry.TT.GO.hdr.size);
- }
-
-
-
- /*
- * AddToTTable
- * Adds an ODP to the translation table
- *
- * Add the necessary information to the LMMsg given for sending the given
- * ODP across the network. Enter the ODP in the Sent Map.
- * Do only once for each ODP -- ignore duplicate requests
- *
- * Local garbage collection support, 3/17/89 cjeffery
- * We set the xref bit whenever we add anything to any ttable.
- */
- void AddToTTable(fHandlePtr, fODP, fSentMap, fARSet)
- LMHandle *fHandlePtr;
- register ODP fODP;
- Map fSentMap;
- Set fARSet;
- {
- char kmddest[8];
-
- strcpy(kmddest,ISCHECKPOINT?"CPTT":"TT");
-
- if (fODP == (ODP) EMNIL) {
- KMDTrace(kmddest, 5, "AddToTTable(EMNIL) -- ignored\n");
- return;
- }
- if (NonNIL(Map_Lookup(fSentMap, (int) fODP))) {
- KMDTrace(kmddest, 5, "AddTT 0x%05x (tag %s) already in table\n", fODP,
- PPODBasicTag(fODP->G.tag.tag));
- return;
- }
- fODP->G.tag.seenHere = TRUE;
- KMDTrace(kmddest, 5, "AddTT: ODP 0x%06x \ttag %s\n", fODP,
- PPODBasicTag(fODP->G.tag.tag));
-
- /* turn on the xref bit; we're adding to the ttable */
- fODP->G.tag.xref = 1;
-
- switch (fODP->G.tag.tag) {
-
- case GODTag:
- if (IsNULL(fODP->G.ownOID)) { /* Baptise and insert into OT */
- OTInsert(fODP);
- }
-
- godEntry.tag = fODP->G.tag;
- godEntry.oldODP = fODP;
- godEntry.ownOID = fODP->G.ownOID;
- godEntry.ownLoc = fODP->G.ownLoc;
- godEntry.myCodeOID = fODP->G.myCodeOID;
-
- KMDTrace(kmddest, 4, "AddTT: GOD : 0x%08.8x (0x%05x) @ 0x%04x Code: %s\n",
- fODP->G.ownOID, fODP, fODP->G.ownLoc, PPCOID(fODP->G.myCodeOID));
-
- if (ISCHECKPOINT) CP_writeCompiledCodeFile(fODP->G.myCodeOID);
-
- PUTDATA(fHandlePtr, &godEntry, sizeof(godEntry));
- Map_Insert(fSentMap, (int) fODP, (int) RefSent);
- break;
-
-
- case SSODTag:
-
- /*CP:should we baptise these??*/
- if (!fODP->SS.ownOID){
- /* Baptise and insert into OT */
- OTInsert(fODP);
- }
- ssodEntry.oldODP = fODP;
- ssodEntry.tag = fODP->SS.tag;
- ssodEntry.ownOID = fODP->SS.ownOID;
- ssodEntry.ownLoc = fODP->SS.ownLoc;
- ssodEntry.processOID =
- (IsNULL(fODP->SS.dataPtr) || IsNIL(fODP->SS.dataPtr)) ? EMNIL : fODP->SS.dataPtr->processOID;
- KMDTrace(kmddest, 4,
- "AddTT: SSOD: 0x%08.8x (0x%05x) @ 0x%04x, Process: 0x%05x\n",
- fODP->SS.ownOID, fODP, fODP->SS.ownLoc,
- ssodEntry.processOID);
- PUTDATA(fHandlePtr, &ssodEntry, sizeof(ssodEntry));
- Map_Insert(fSentMap, (int) fODP, (int)RefSent);
- break;
-
-
- case CodeODTag:
- codeodEntry.oldODP = (ODP) fODP->C.dataPtr;
- codeodEntry.tag = fODP->C.tag;
- codeodEntry.ownOID = fODP->C.ownOID;
- codeodEntry.ownLoc = fODP->C.ownLoc;
- KMDTrace(kmddest, 4, "AddTT: C OD: (dataptr 0x%05x) @ 0x%02x %s\n",
- fODP->C.dataPtr, fODP->C.ownLoc, PPCOID(fODP->C.ownOID));
- /*bosch*/
- PUTDATA(fHandlePtr, &codeodEntry, sizeof(codeodEntry));
- Map_Insert(fSentMap, (int) fODP, (int)RefSent);
- break;
-
-
- case GODataTag:
- KMDTrace("FixMe", 2,
- "AddToTT: recoverable compiler bug: tag should be LOTag\n");
- /* Fix the problem and continue !!!!!!*/
- fODP->L.tag.tag = LOTag;
- /* Fall thru to LOTag !!! */
-
- case LOTag: {
- register CodePtr theCodePtr = fODP->L.myCodePtr;
-
- assert (NonNULL(theCodePtr));
- if (!theCodePtr->tag.replicated) {
- ErrMsg("AddTT: LO : must be replicated\n");
- abort();
- }
- /* and now the same as move */
- MoveToTTable(fHandlePtr, fODP, fSentMap, fARSet);
- break;
- }
-
- case AbConTag:
- abconEntry.tag = fODP->AB.tag;
- abconEntry.oldODP = fODP;
- abconEntry.ATOID = fODP->AB.ATOID;
- abconEntry.restrictOID = fODP->AB.restrictOID;
- abconEntry.CodeOID = fODP->AB.CodeOID;
- KMDTrace(kmddest, 4, "AddTT: AbCon(0x%05x): AT %s rAT %s CT %s\n",
- fODP, PPCOID(fODP->AB.ATOID), PPCOID(fODP->AB.restrictOID),
- PPCOID(fODP->AB.CodeOID));
- PUTDATA(fHandlePtr, &abconEntry, sizeof(abconEntry));
- Map_Insert(fSentMap, (int) fODP, (int)RefSent);
- break;
-
-
- case CondTag:
- if (IsNULL(fODP->CD.ownOID)) { /* Baptise and insert into OT */
- OTInsert(fODP);
- }
-
- condEntry.tag = fODP->CD.tag;
- condEntry.oldODP = fODP;
- condEntry.ownOID = fODP->CD.ownOID;
- condEntry.ownLoc = fODP->CD.ownLoc;
-
- KMDTrace(kmddest, 4, "AddTT: CondOD: %s (0x%05x) @ %s\n",
- PPOID(fODP->CD.ownOID), fODP, PPLoc(fODP->CD.ownLoc));
- PUTDATA(fHandlePtr, &condEntry, sizeof(condEntry));
- Map_Insert(fSentMap, (int) fODP, (int) RefSent);
- break;
-
-
- default:
- ErrMsg("Cannot AddTT: tag %s\n", PPODBasicTag(fODP->G.tag.tag));
- abort();
- }
- }
-
-
-
- /*
- * TranslateVar
- */
- void TranslateVar(fVarPtr, fTMap)
- AVariablePtr fVarPtr;
- Map fTMap;
- {
- register AVariablePtr v = fVarPtr;
- register AbConPtr oldAbConPtr, newAbConPtr;
- register DataAddr oldAddr;
-
- if (IsNIL(v->myAbConPtr)) {
- KMDTrace("TT", 5, "TT: Var is NIL\n");
- } else {
- /* Translate AbCon */
- oldAbConPtr = v->myAbConPtr;
- newAbConPtr = (AbConPtr) Map_Lookup(fTMap, (int) oldAbConPtr);
- v->myAbConPtr = newAbConPtr;
- assert(NonNIL(newAbConPtr));
- if (IsNIL(v->myAddr)) {
- KMDTrace("TT", 5, "TT: Var is NIL; viewed as %s\n",
- PPCOID(newAbConPtr->ATOID));
- } else if (newAbConPtr->tag.hasNoPointer) {
- KMDTrace("TT", 5, "TT: Var is data: %d; one of %s viewed as %s\n",
- v->myAddr, PPCOID(v->myAbConPtr->CodeOID),
- PPCOID(v->myAbConPtr->ATOID));
- } else {
- /* Translate ODP */
- oldAddr = v->myAddr;
- v->myAddr = (SSAddr) Map_Lookup(fTMap, (int) v->myAddr);
- KMDTrace("TT", 5, "TT: Var (0x%06x -> 0x%06x) one of %s; viewed as %s\n",
- oldAddr, v->myAddr, PPCOID(newAbConPtr->CodeOID),
- PPCOID(newAbConPtr->ATOID));
- }
- }
- }
-
-
-
- /*
- * AddVarToTTable
- */
- void AddVarToTTable(fHandlePtr, fVarPtr, fSentMap, fARSet)
- LMHandle *fHandlePtr;
- AVariablePtr fVarPtr;
- Map fSentMap;
- Set fARSet;
- {
- register AVariablePtr v = fVarPtr;
- char kmddest[8];
- strcpy(kmddest,ISCHECKPOINT?"CPTT":"TT");
-
- if (IsNIL(v->myAbConPtr)) {
- KMDTrace(kmddest, 5, "TT: Var is NIL\n");
- } else if (IsNIL(v->myAddr)) {
- KMDTrace(kmddest, 5, "TT: Var is NIL (viewed as %s)\n",
- PPCOID(v->myAbConPtr->ATOID));
- AddToTTable(fHandlePtr,(ODP) v->myAbConPtr, fSentMap, fARSet);
- } else if (v->myAbConPtr->tag.hasNoPointer) {
- KMDTrace(kmddest, 5, "TT: Var is data: %d; one of %s\n", v->myAddr,
- PPCOID(v->myAbConPtr->CodeOID));
- AddToTTable(fHandlePtr,(ODP) v->myAbConPtr, fSentMap, fARSet);
- } else {
- KMDTrace(kmddest, 5, "TT: Var is 0x%05x; one of %s viewed as %s\n",
- v->myAddr, PPCOID(v->myAbConPtr->CodeOID),
- PPCOID(v->myAbConPtr->ATOID));
- AddToTTable(fHandlePtr,(ODP) v->myAbConPtr, fSentMap, fARSet);
- AddToTTable(fHandlePtr, (ODP) v->myAddr, fSentMap, fARSet);
- }
- }
-
-
-
- /*
- * MoveVarToTTable
- */
- void MoveVarToTTable(fHandlePtr, fVarPtr, fSentMap, fARSet)
- LMHandle *fHandlePtr;
- AVariablePtr fVarPtr;
- Map fSentMap;
- Set fARSet;
- {
- register AVariablePtr v = fVarPtr;
- char kmddest[8];
- strcpy(kmddest,ISCHECKPOINT?"CPTT":"TT");
-
- if (IsNIL(v->myAbConPtr)) {
- KMDTrace(kmddest, 5, "TT: Var is NIL\n");
- } else if (IsNIL(v->myAddr)) {
- KMDTrace(kmddest, 5, "TT: Var is NIL (viewed as %s)\n",
- PPCOID(v->myAbConPtr->CodeOID));
- AddToTTable(fHandlePtr,(ODP) v->myAbConPtr, fSentMap, fARSet);
- } else if (v->myAbConPtr->tag.hasNoPointer) {
- KMDTrace(kmddest, 5, "Var is data: %d; one of %s\n", v->myAddr,
- PPCOID(v->myAbConPtr->CodeOID));
- AddToTTable(fHandlePtr,(ODP) v->myAbConPtr, fSentMap, fARSet);
- } else {
- KMDTrace(kmddest, 5, "Var is 0x%05x; one of %s viewed as %s\n",
- v->myAddr, PPCOID(v->myAbConPtr->CodeOID),
- PPCOID(v->myAbConPtr->ATOID));
- AddToTTable(fHandlePtr,(ODP) v->myAbConPtr, fSentMap, fARSet);
- MoveToTTable(fHandlePtr, (ODP) v->myAddr, fSentMap, fARSet);
- }
- }
-
-
-
- /*
- * AddCodeAddrToTTable
- */
- void AddCodeAddrToTTable(fHandlePtr, fCodePtr, fIP, fSentMap, fARSet)
- LMHandle *fHandlePtr;
- CodePtr fCodePtr;
- CodeAddr fIP;
- Map fSentMap;
- Set fARSet;
- {
- int kernelOpNumber;
- Offset theOffset;
- RefStatus status;
-
- status = (RefStatus) Map_Lookup(fSentMap, (int) fIP);
-
- if ((int) status != EMNIL) {
- KMDTrace("TT", 5, "AddTT 0x%05x already in map\n", fIP);
- return;
- }
-
- Map_Insert(fSentMap, (int) fIP, (int)RefSent);
-
- if (IsNULL(fCodePtr)) {
- /* It is an address of a return-to-kernel routine */
- kernelOpNumber = Map_Lookup(KernelReturnAddressMap, (int) fIP);
- if (IsNIL(kernelOpNumber)) {
- ErrMsg("Bad IP 0x%06x in AddCodeAddrToTTable\n", fIP);
- abort();
- }
- codeaddrEntry.oldODP = (ODP) fIP;
- codeaddrEntry.theCodeOID = (OID) NULL;
- codeaddrEntry.theOffset = (Offset) kernelOpNumber;
- KMDTrace("TT", 4, "AddTT: 0x%06x Kernel op number #%d\n", fIP,
- kernelOpNumber);
- LMPutData(fHandlePtr, &codeaddrEntry, sizeof(codeaddrEntry));
- } else {
- AddToTTable(fHandlePtr, OTLookup(fCodePtr->ownOID), fSentMap, fARSet);
- /* It is an address in Emerald compiled code. */
- codeaddrEntry.oldODP = (ODP) fIP;
- codeaddrEntry.theCodeOID = (OID) fCodePtr->ownOID;
- theOffset = (Offset) byteOffset(fCodePtr, fIP);
- codeaddrEntry.theOffset = theOffset;
- KMDTrace("TT", 4, "AddTT: Code Addr 0x%06x (%d) in %s, line %s\n",
- fIP, theOffset, PPCodePtr(fCodePtr), PPFindLineNo(fCodePtr, fIP));
- LMPutData(fHandlePtr, &codeaddrEntry, sizeof(codeaddrEntry));
- }
- }
-
-
-
- /*
- * MoveToTTable
- *
- * Add the necessary information to the LMMsg given for sending the given
- * ODP across the network. Enter the ODP in the SentMap.
- * Enter any ARs that are to move in the fARSet.
- * Do only once for each ODP -- ignore duplicate requests
- *
- * Checkpoint support merged 7/22/88 cjeffery
- * A null fHandlePtr => we are doing a checkpoint. This is used throughout
- * the move delivery subsystem.
- *
- * Local garbage collection support added 3/17/89 cjeffery
- * We set the xref bit whenever we move anything anywhere.
- */
- void MoveToTTable(fHandlePtr, fODP, fSentMap, fARSet)
- LMHandle *fHandlePtr;
- register ODP fODP;
- Map fSentMap;
- Set fARSet;
- {
- NodeNum destLNN;
- RefStatus status;
- int instanceSize;
- char kmddest[12], kmdttdest[8];
- strcpy(kmddest,ISCHECKPOINT ? "Checkpoint": "Move");
- strcpy(kmdttdest,ISCHECKPOINT ? "CPTT": "TT");
-
- if (fODP == (ODP) EMNIL) {
- KMDTrace(kmdttdest, 5, "MoveToTTable(EMNIL) -- ignored\n");
- return;
- }
- status = (RefStatus) Map_Lookup(fSentMap, (int) fODP);
-
- if (((int) status != EMNIL) && (status == RefMoved) ) {
- KMDTrace(kmdttdest, 5, "MoveTT 0x%05x already %sd\n", fODP, kmddest);
- return;
- }
-
- Map_Insert(fSentMap, (int) fODP, (int)RefMoved);
- fODP->G.tag.seenHere = TRUE;
-
- if(!ISCHECKPOINT) destLNN = (*fHandlePtr)->mmMsgHdr.MsgDest;
-
- /* turn on the xref bit; if it moves we won't collect it! */
- fODP->G.tag.xref = 1;
-
- switch (fODP->G.tag.tag) {
-
- case GODTag: {
- register CodePtr theCodePtr;
- register GODP x;
- AbConPtr theAbCon;
- CodeODP theCodeODP;
-
- x = &fODP->G;
- if (!x->tag.isResident) {
- if(ISCHECKPOINT){
- KMDTrace("Checkpoint", 2,
- "Process %s fails, 0x%05x nonresident; unavailable in %s\n",
- PPPOID(currentSSP->processOID), fODP, PPSSPlace(currentSSP));
-
- /* Checkpoint does an unavailable exception if an object
- * being Checkpointed is not resident.
- */
- theAbCon = OIDOIDOIDToAbCon(x->dataPtr->myCodePtr->ownAbstractType,
- (OID)EMNIL,
- x->dataPtr->myCodePtr->ownOID);
- unavail(preemptRunning(), x, theAbCon);
- return;
- } else { /* !ISCHECKPOINT */
- fetchgodEntry.tag = fODP->G.tag;
- fetchgodEntry.oldODP = fODP;
- fetchgodEntry.ownOID = fODP->G.ownOID;
- fetchgodEntry.ownLoc = fODP->G.ownLoc;
- fetchgodEntry.myCodeOID = fODP->G.myCodeOID;
- KMDTrace("TT", 4, "AddTT: FetchGOD : %s (0x%05x) @ %s Code: %s\n",
- PPGOID(fODP->G.ownOID), fODP, PPLoc(fODP->G.ownLoc),
- PPCOID(fODP->G.myCodeOID));
- LMPutData(fHandlePtr, &fetchgodEntry, sizeof(fetchgodEntry));
- Map_Insert(fSentMap, (int) fODP, (int)RefSent);
- break;
- }
- }
-
- theCodePtr = fODP->G.dataPtr->myCodePtr;
- theCodeODP = (CodeODP) OTLookup(theCodePtr->ownOID);
-
- /* Ensure that CodeODP is sent along */
- MoveToTTable(fHandlePtr, (ODP) theCodeODP, fSentMap, fARSet);
-
- if (IsNULL(fODP->G.ownOID)) { /* Baptise and insert into OT */
- OTInsert(fODP);
- KMDTrace(kmdttdest, 5,
- "%sTT: assigning OID %s to global object 0x%04x\n",
- kmddest,PPOID(fODP->G.ownOID), fODP);
- }
-
- /* Commit the move */
- if(ISCHECKPOINT) {
- #ifdef UNDEF
- /* fODP->G.tag.frozen = TRUE; if we do this, where to undo it??*/
- fODP->G.tag.isFixed = TRUE;
- #endif
- } else {
- fODP->G.tag.isResident = FALSE;
- fODP->G.tag.frozen = TRUE;
- fODP->G.ownLoc =
- mMakeLocation(destLNN, ((mGetLocTimeStamp(fODP->G.ownLoc)) + 1));
- }
-
- instanceSize = theCodePtr->instanceSize;
- if (instanceSize < 0) {
- instanceSize = FindVectorSize((VectorPtr) (fODP->G.dataPtr));
- KMDTrace("Vector", 4, "Vector Instance size %d\n", instanceSize);
- if ((instanceSize % sizeof(ODP)) != 0) {
- /* Round up */
- instanceSize += sizeof(ODP) - (instanceSize % sizeof(ODP));
- KMDTrace(kmdttdest,4, "\tSize rounded up to %d bytes\n", instanceSize);
- }
- }
-
- movegodEntry.hdr.size = sizeof(movegodEntry) + instanceSize;
- movegodEntry.tag = fODP->G.tag;
- movegodEntry.oldODP = fODP;
- movegodEntry.ownOID = fODP->G.ownOID;
- movegodEntry.ownLoc = fODP->G.ownLoc;
- movegodEntry.myCodeOID = fODP->G.myCodeOID;
- movegodEntry.oldGODataPtr = fODP->G.dataPtr;
- KMDTrace(kmddest, 3,
- "Moving GOD %s to %s, one of %s\n", PPGOID(fODP->G.ownOID),
- PPLoc(fODP->G.ownLoc), PPCOID(fODP->G.myCodeOID));
- KMDTrace(kmdttdest, 4, "MoveTT: GOD: %s (0x%05x) @ %s Code: %s\n",
- PPGOID(fODP->G.ownOID), fODP, PPLoc(fODP->G.ownLoc),
- PPCOID(fODP->G.myCodeOID));
- if (ISCHECKPOINT) CP_writeCompiledCodeFile(fODP->G.myCodeOID);
- PUTDATA(fHandlePtr, &movegodEntry, sizeof(movegodEntry));
- PUTDATA(fHandlePtr, fODP->G.dataPtr, instanceSize);
-
- /* Traverse and send components */
- TraverseAndMove(fHandlePtr, (ODP) fODP->G.dataPtr, fSentMap, fARSet);
-
- /* Traverse AR list and send components */
- if(!ISCHECKPOINT) TraverseAndMoveARList(&fODP->G, fARSet);
-
- break;
- }
-
- case CodeODTag: {
- movecodeodEntry.oldODP = (ODP) fODP->C.dataPtr;
- movecodeodEntry.tag = fODP->C.tag;
- movecodeodEntry.ownOID = fODP->C.ownOID;
- movecodeodEntry.ownLoc = fODP->C.ownLoc;
- KMDTrace(kmdttdest, 4, "MoveTT: C OD: 0x%04x (dataptr 0x%05x) @ 0x%04x\n",
- fODP->C.ownOID, fODP->C.dataPtr, fODP->C.ownLoc);
- PUTDATA(fHandlePtr, &movecodeodEntry, sizeof(movecodeodEntry));
- break;
- }
-
- case LOTag: {
- register CodePtr theCodePtr;
- CodeODP theCodeODP;
- int linstanceSize;
-
- theCodePtr = fODP->L.myCodePtr;
- assert (NonNULL(theCodePtr));
-
- theCodeODP = (CodeODP) OTLookup(theCodePtr->ownOID);
- if (ISCHECKPOINT) CP_writeCompiledCodeFile(theCodePtr->ownOID);
- AddToTTable(fHandlePtr, (ODP) theCodeODP, fSentMap, fARSet);
-
- KMDTrace(kmdttdest, 4, "MoveTT: LO : (0x%05x) CT 0x%04x size %d, %s\n",
- fODP, theCodePtr->ownOID, theCodePtr->instanceSize, PPODP(fODP));
-
- if (fODP->L.tag.replicated) {
- register RODataPtr theObj;
- theObj = (RODataPtr) fODP;
- if (IsNIL(theObj->ownOID) || IsNULL(theObj->ownOID)) {
- theObj->ownOID = getNextOID();
- OTInsert((ODP) theObj);
- KMDTrace(kmdttdest, 5,
- "MoveTT: assinging OID %s to replicated object 0x%04x\n",
- PPOID(theObj->ownOID), theObj);
- }
- }
-
- linstanceSize = theCodePtr->instanceSize;
-
- KMDTrace(kmdttdest, 4, "\tSize %d bytes\n", linstanceSize);
- if (linstanceSize < 0) {
- /* Vector */
- linstanceSize = FindVectorSize((VectorPtr) fODP);
- KMDTrace(kmdttdest, 4, "\tSize %d bytes\n", linstanceSize);
- if ((linstanceSize % sizeof(ODP)) != 0) {
- /* Round up */
- linstanceSize += sizeof(ODP) - (linstanceSize % sizeof(ODP));
- KMDTrace(kmdttdest,4,"\tSize rounded up to %d bytes\n", linstanceSize);
- }
- }
-
- loEntry.hdr.size = linstanceSize + (sizeof(loEntry)-sizeof(ODTag));
- loEntry.oldODP = fODP;
- PUTDATA(fHandlePtr, &loEntry, sizeof(loEntry)-sizeof(ODTag));
- PUTDATA(fHandlePtr, fODP, linstanceSize);
-
- /* Traverse and send components */
- TraverseAndMove(fHandlePtr, fODP, fSentMap, fARSet);
- break;
- }
-
- case AbConTag: {
- abconEntry.tag = fODP->AB.tag;
- abconEntry.oldODP = fODP;
- abconEntry.ATOID = fODP->AB.ATOID;
- abconEntry.restrictOID = fODP->AB.restrictOID;
- abconEntry.CodeOID = fODP->AB.CodeOID;
- KMDTrace(kmdttdest, 4, "MoveTT: AB : AT 0x%04x CT 0x%08x (0x%05x)\n",
- fODP->AB.ATOID, fODP->AB.CodeOID, fODP);
- KMDTrace(kmdttdest, 5, "\t%s viewed as %s restricted to %s\n",
- PPCOID(fODP->AB.CodeOID), PPCOID(fODP->AB.ATOID),
- PPCOID(fODP->AB.restrictOID));
- PUTDATA(fHandlePtr, &abconEntry, sizeof(abconEntry));
- break;
- }
-
- default:
- ErrMsg("Cannot Move, tag %s\n", PPODBasicTag(fODP->G.tag.tag));
- abort();
- }
- }
-
-
-
- /*
- * DigestTable
- *
- * Read a translation table out of the message, stop when
- * either the msg is emptied or when a non-translation item is found.
- * Build a translation map: oldODP -> newODP for the things that
- * can be translated right now (everything except code that needs to be
- * loaded).
- * Build a load map of the Code OIDs that need to be loaded before
- * translation. CTOID -> oldODP
- * Build a set, fNewSet, of the newly arrived data areas (excluding code
- * areas). These areas are the ones that need to be translated.
- */
- void DigestTable(fHandlePtr, fTMap, fLoadMap, fNewSet, isRecovery)
- LMHandle *fHandlePtr; /* replicantPtr if isRecovery */
- Map fTMap, fLoadMap;
- Set fNewSet;
- int isRecovery; /* TRUE implies we are doing RecoverDigestTable(); */
- {
- register ODP entry;
- register CodeODP codeEntry;
- int length;
- TTableEntry theEntry;
-
- register TTableEntryPtr t = &theEntry;
-
- KMDTrace("TT", 3, "%sDigestTable\n",isRecovery?"Recover":"");
-
- /* Get the Item hdr and the OD tag of the thing. */
- length = sizeof(TTGenericEntry);
-
- GETDATA(fHandlePtr, t, &length);
- while ( (length == sizeof(TTGenericEntry))
- && ((int) t->TT.GO.hdr.itemTag > (int) TTFirstITag)
- && ((int) t->TT.GO.hdr.itemTag < (int) TTLastITag)) {
- KMDTrace("TT", 3, "ITag is %s, size %d bytes\n",
- PPITag(t->TT.GO.hdr.itemTag), t->TT.GO.hdr.size);
-
- switch (t->TT.GO.hdr.itemTag) {
-
- case TTGODITag: {
- /* Get rest of GODEntry */
- length = sizeof(TTGODEntry) - sizeof(TTGenericEntry);
- GETDATA(fHandlePtr, addOffset(t,sizeof(TTGenericEntry)), &length);
- entry = OTLookup(t->TT.GO.ownOID);
- if (IsNULL(entry)) {
- /* Insert a new entry */
- entry = getFreeOD();
- entry->G.ownOID = t->TT.GO.ownOID;
- entry->G.tag = t->TT.GO.tag;
- entry->G.tag.frozen = TRUE;
- entry->G.tag.isResident = FALSE;
- entry->G.ownLoc = t->TT.GO.ownLoc;
- entry->G.ARListHead.next = entry->G.ARListHead.prev =
- (InvokeQueuePtr) &entry->G.ARListHead;
- entry->G.myCodeOID = t->TT.GO.myCodeOID;
- /* Lookup and insert code, if necessary */
- codeEntry = (CodeODP) OTLookup(t->TT.GO.myCodeOID);
- if (IsNULL(codeEntry)) { /* Create an entry */
- codeEntry = CreateCodeODEntry(t->TT.GO.myCodeOID,t->TT.GO.ownLoc);
- } else { /* Verify that it is a code entry */
- assert(codeEntry->tag.tag == CodeODTag);
- }
- OTInsert(entry);
- } else {
- assert (entry->G.tag.tag == t->TT.GO.tag.tag);
- /* Check to see if location timestamp is newer */
- if (LOCATIONNEWER(t->TT.GO.ownLoc, entry->SS.ownLoc)) {
- KMDTrace("TT", 3, "GO OID 0x%05x was @ 0x%04x now @ 0x%04x\n",
- entry->G.ownOID, entry->G.ownLoc, t->TT.GO.ownLoc);
- entry->G.ownLoc = t->TT.GO.ownLoc;
- KMDTrace("FixMe", 5, "Fix me: should reset ODTag flags.\n");
- }
- }
- Map_Insert(fTMap, (int) t->TT.GO.oldODP, (int) entry);
- KMDTrace("TT", 4,
- "TT GOD 0x%04x %-9.9s@0x%04x (0x%05x)->(0x%05x) CT 0x%05x\n",
- t->TT.GO.ownOID, BasicTagName[(int) t->TT.GO.tag.tag],
- t->TT.GO.ownLoc, t->TT.GO.oldODP, entry, t->TT.GO.myCodeOID);
- break;
- }
-
- case TTSSODITag: {
- if(isRecovery){
- ErrMsg("Should never get an SSODITag in RecoverDigestTable #1!");
- abort();
- } else {
- /* Get rest of Entry */
- length = sizeof(TTSSODEntry) - sizeof(TTGenericEntry);
- LMGetData(fHandlePtr, addOffset(t, sizeof(TTGenericEntry)), &length);
- entry = (ODP) OTLookup(t->TT.SS.ownOID);
- if (IsNULL(entry)) {
- /* Insert new SSOD entry */
- entry = getFreeOD();
- entry->SS.tag = t->TT.SS.tag;
- entry->SS.tag.isResident = FALSE;
- entry->SS.ownOID = t->TT.SS.ownOID;
- entry->SS.ownLoc = t->TT.SS.ownLoc;
- entry->SS.processOID = t->TT.SS.processOID;
- OTInsert(entry);
- } else {
- assert (entry->SS.tag.tag == t->TT.SS.tag.tag);
- /* Check to see if location timestamp is newer */
- if (LOCATIONNEWER(t->TT.SS.ownLoc, entry->SS.ownLoc)) {
- KMDTrace("TT", 3, "SS OID 0x%05x was @ 0x%04x now @ 0x%04x\n",
- entry->SS.ownOID, entry->SS.ownLoc, t->TT.SS.ownLoc);
- entry->SS.ownLoc = t->TT.SS.ownLoc;
- KMDTrace("FixMe", 3, "Fix me: should reset ODTag flags.\n");
- }
- }
- Map_Insert(fTMap, (int) t->TT.SS.oldODP, (int) entry);
- KMDTrace("TT", 4,
- "TT 0x%04x %-9.9s@0x%04x (0x%05x)->(0x%05x) Process %s\n",
- t->TT.SS.ownOID, BasicTagName[(int) t->TT.SS.tag.tag],
- t->TT.SS.ownLoc, t->TT.SS.oldODP, entry,
- PPPOID(t->TT.SS.processOID));
- break;
- }
- }
-
- case TTCodeODITag: {
- register CodeODP theCodeODP;
- /* Get rest of Entry */
- length = sizeof(TTCEntry) - sizeof(TTGenericEntry);
- GETDATA(fHandlePtr, addOffset(t, sizeof(TTGenericEntry)), &length);
-
- assert (length == sizeof(TTCEntry) - sizeof(TTGenericEntry));
- theCodeODP = (CodeODP) OTLookup(t->TT.C.ownOID);
- if (IsNULL(theCodeODP)) {
- /* Create an entry for some unknown code object */
- theCodeODP = CreateCodeODEntry(t->TT.C.ownOID, t->TT.C.ownLoc);
- }
- if (!theCodeODP->tag.setUpDone) {
- Map_Insert(fLoadMap, (int) theCodeODP->ownOID, (int) t->TT.C.oldODP);
- KMDTrace("TT", 4, "TT C (0x%04x) do not have %s\n",
- t->TT.LO.oldODP, PPCOID(t->TT.C.ownOID));
- } else {
- KMDTrace("TT", 4, "TT C (0x%05x) -> (0x%05x)\n",
- t->TT.LO.oldODP, theCodeODP);
- Map_Insert(fTMap, (int) t->TT.C.oldODP, (int) theCodeODP->dataPtr);
- }
- break;
- }
-
- case TTLOITag: {
- int instanceSize, residual;
- register LODataPtr newODP;
- register RODataPtr candidateODP;
-
- /* Get rest of Entry */
- residual = sizeof(TTLOEntry) - sizeof(TTGenericEntry);
- if (residual>0) {
- GETDATA(fHandlePtr, addOffset(t, sizeof(TTGenericEntry)), &residual);
- assert(residual == (sizeof(TTLOEntry)-sizeof(TTGenericEntry)));
- }
- instanceSize = t->TT.LO.hdr.size + (sizeof(ODTag)-sizeof(TTLOEntry));
- assert (instanceSize > 0 && instanceSize < 1000000);
-
- newODP = (LODataPtr) emallocnil(instanceSize);
- newODP->tag = t->TT.LO.tag;
- length = instanceSize - sizeof(ODTag);
- GETDATA(fHandlePtr, addOffset(newODP, sizeof(ODTag)), &length);
- assert(length == instanceSize - sizeof(ODTag));
-
- Set_Insert(fNewSet, (int) newODP);
-
- if (newODP->tag.replicated) {
- /* Check to see if we already know it */
- candidateODP = (RODataPtr) OTLookup(((RODataPtr) newODP)->ownOID);
- if (IsNULL(candidateODP)) {
- /* Do not know it; remember it now */
- OTInsert(((ODP) newODP));
- KMDTrace("TT", 4, "TT LO is replicated; first time here; OID %s\n",
- PPOID(((RODataPtr)newODP)->ownOID));
- } else {
- /* We already have a copy */
- KMDTrace("TT", 4, "TT LO is replicated; OID %s\n",
- PPOID(((RODataPtr)newODP)->ownOID));
- /* UNDO the new version and use the old one */
- Set_Delete(fNewSet, (int) newODP);
- emfree((char *)newODP);
- newODP = (LODataPtr) candidateODP;
- }
- }
- /* Insert the translation information into Translation Map */
- Map_Insert(fTMap, (int) t->TT.LO.oldODP, (int) newODP);
-
- KMDTrace("TT", 4, "TT LO size %d (0x%05x) -> (0x%05x)\n",
- instanceSize, t->TT.LO.oldODP, newODP);
- break;
- }
-
- case TTAbConITag: {
- /* Get rest of Entry */
- length = sizeof(TTAbConEntry) - sizeof(TTGenericEntry);
- GETDATA(fHandlePtr, addOffset(t, sizeof(TTGenericEntry)), &length);
- entry = (ODP) GetAbCon(t->TT.AB.ATOID, t->TT.AB.restrictOID,
- t->TT.AB.CodeOID, t->TT.AB.tag);
- Map_Insert(fTMap, (int) t->TT.AB.oldODP, (int) entry);
- KMDTrace("TT", 4,
- "TT AT 0x%04x rAT 0x%04x CT 0x%04x %-9.9s (0x%05x)->(0x%05x)\n",
- t->TT.AB.ATOID, t->TT.AB.restrictOID, t->TT.AB.CodeOID,
- BasicTagName[(int) t->TT.AB.tag.tag],
- t->TT.AB.oldODP, entry);
- break;
- }
-
- case TTMoveGODITag: {
- int instanceSize;
- GODataPtr theData;
-
- /* Get rest of GODEntry */
- length = sizeof(TTMoveGODEntry) - sizeof(TTGenericEntry);
- GETDATA(fHandlePtr, addOffset(t, sizeof(TTGenericEntry)), &length);
- entry = OTLookup(t->TT.MGOD.ownOID);
- if (IsNULL(entry)) {
- /* Insert a new entry */
- entry = getFreeOD();
- entry->G.ownOID = t->TT.MGOD.ownOID;
- entry->G.tag = t->TT.MGOD.tag;
- entry->G.tag.frozen = TRUE;
- entry->G.tag.isResident = TRUE;
- entry->G.tag.setUpDone = FALSE;
- entry->G.ownLoc = NewLocation(t->TT.MGOD.ownLoc, GetLNN());
- entry->G.ARListHead.next = entry->G.ARListHead.prev =
- (InvokeQueuePtr) &entry->G.ARListHead;
- entry->G.myCodeOID = t->TT.MGOD.myCodeOID;
- OTInsert(entry);
- } else {
- assert (entry->G.tag.tag == t->TT.MGOD.tag.tag);
- /* Check to see if location timestamp is newer */
- if (LOCATIONNEWER(t->TT.MGOD.ownLoc, entry->G.ownLoc)) {
- KMDTrace("TT", 3,
- "MoveGO OID 0x%05x was @ 0x%04x now @ 0x%04x\n",
- entry->G.ownOID, entry->G.ownLoc, t->TT.MGOD.ownLoc);
- entry->G.ownLoc = NewLocation(t->TT.MGOD.ownLoc,GetLNN());
- entry->G.tag.isResident = TRUE;
- entry->G.tag.frozen = !t->TT.MGOD.tag.setUpDone;
- KMDTrace("FixMe", 5,"Fix me: should reset ODTag flags properly.\n");
- }
- }
- /* Lookup and insert code, if necessary */
- codeEntry = (CodeODP) OTLookup(t->TT.MGOD.myCodeOID);
- if (IsNULL(codeEntry)) { /* Create an entry */
- codeEntry = CreateCodeODEntry(t->TT.MGOD.myCodeOID, t->TT.MGOD.ownLoc);
- } else { /* Verify that it is a code entry */
- assert(codeEntry->tag.tag == CodeODTag);
- }
- KMDTrace("TT", 4,
- "TTM 0x%04x %-9.9s@ 0x%04x (0x%05x)->(0x%05x) CT %s\n",
- t->TT.MGOD.ownOID, BasicTagName[(int) t->TT.MGOD.tag.tag],
- t->TT.MGOD.ownLoc, t->TT.MGOD.oldODP, entry,
- PPCOID(t->TT.MGOD.myCodeOID));
- entry->G.tag.setUpDone = FALSE;
- entry->G.tag.frozen = TRUE;
-
- /* Now get the data area */
- instanceSize = t->TT.MGOD.hdr.size - sizeof(TTMoveGODEntry);
- /* Hack: if there already is a data area, free it */
- if (NonNULL(entry->G.dataPtr) &&
- PPValidAddr((SSAddr *) entry->G.dataPtr) &&
- entry->G.dataPtr->tag.tag == GODataTag) {
- emfree((char *)entry->G.dataPtr);
- }
-
- entry->G.dataPtr = theData = (GODataPtr) emalloc(instanceSize);
- KMDTrace("FixMe", 4, "Consider whether tag should change\n");
- length = instanceSize;
- GETDATA(fHandlePtr, theData, &length);
- assert(length == instanceSize);
-
- if (!codeEntry->tag.setUpDone) {
- KMDTrace("TT", 4, "%s causing req for Code C%08x (old cPtr 0x%06x)\n",
- (isRecovery?"Recover":"Move"),
- codeEntry->ownOID, theData->myCodePtr);
- Map_Insert(fLoadMap, (int) codeEntry->ownOID, (int) theData->myCodePtr);
- } else {
- KMDTrace("TT", 4, "TT: (0x%06x -> 0x%06x) for codePtr %s\n",
- theData->myCodePtr, codeEntry->dataPtr,
- PPCodePtr(codeEntry->dataPtr));
- Map_Insert(fTMap, (int) theData->myCodePtr, (int) codeEntry->dataPtr);
- }
-
- /* Insert into translation map */
- Map_Insert(fTMap, (int) t->TT.MGOD.oldODP, (int) entry);
- Map_Insert(fTMap, (int) t->TT.MGOD.oldGODataPtr, (int) theData);
-
- /* Insert object into map of newly arrived objects */
- Set_Insert(fNewSet, (int) entry);
-
- KMDTrace((isRecovery?"Recover":"Move"), 3, "Object %s %s here.\n",
- PPGOID(entry->G.ownOID), (isRecovery?"recovered":"moved to"));
- break;
- }
-
- case TTMoveCITag: {
- register CodeODP theCodeODP;
- /* Get rest of entry */
- length = sizeof(TTMoveCEntry) - sizeof(TTGenericEntry);
- GETDATA(fHandlePtr, addOffset(t, sizeof(TTGenericEntry)),&length);
- assert (length == sizeof(TTMoveCEntry) - sizeof(TTGenericEntry));
- theCodeODP = (CodeODP) OTLookup(t->TT.MC.ownOID);
- if (IsNULL(theCodeODP)) {
- /* Create an entry for some unknown code object */
- theCodeODP = CreateCodeODEntry(t->TT.MC.ownOID, t->TT.MC.ownLoc);
- }
- if (!theCodeODP->tag.setUpDone) {
- /* We need to load it so put it into the load map */
- KMDTrace("TT", 4, "TT: MoveC: Req for Code C%08x (old cPtr 0x%06x)\n",
- t->TT.MC.ownOID, t->TT.MC.oldODP);
- Map_Insert(fLoadMap, (int) t->TT.MC.ownOID, (int) t->TT.MC.oldODP);
- } else {
- theCodeODP->ownLoc = t->TT.MC.ownLoc;
- KMDTrace("TT", 4, "TT: MoveC: (0x%06x -> 0x%06x) codePtr for %s\n",
- t->TT.MC.oldODP, theCodeODP->dataPtr,
- PPCOID(theCodeODP->ownOID));
- Map_Insert(fTMap, (int) t->TT.MC.oldODP, (int) theCodeODP->dataPtr);
- }
- break;
- }
-
- case TTCodeAddrITag: {
- if(isRecovery){
- ErrMsg("RecoverDigestTable: TTCodeAddrITag in recovered object?");
- abort();
- } else {
- OID theOID;
- Offset theOffset;
- CodeAddr newAddr;
- CodeODP theCodeODP;
- TRecPtr tRec;
-
-
- /* Get rest of entry */
- length = sizeof(TTCodeAddrEntry) - sizeof(TTGenericEntry);
- LMGetData(fHandlePtr, addOffset(t, sizeof(TTGenericEntry)),&length);
- assert (length == sizeof(TTCodeAddrEntry)-sizeof(TTGenericEntry));
-
- /* Forget it, if it is already there */
- if (NonNIL(Map_Lookup(fTMap, (int) t->TT.CA.oldODP))) break;
-
- theOID = t->TT.CA.theCodeOID;
- theOffset = t->TT.CA.theOffset;
- if (IsNULL(theOID)) {
- /* It is an address of a return-to-kernel routine */
- newAddr = (CodeAddr) Map_Lookup(KernelReturnOpNumberMap, (int) theOffset);
- KMDTrace("TT", 4, "TT: Kernel addr 0x%06x -> 0x%06x op #%d\n",
- t->TT.CA.oldODP, newAddr, theOffset);
- Map_Insert(fTMap, (int) t->TT.CA.oldODP, (int) newAddr);
- } else {
- /* It is an address in Emerald code */
- theCodeODP = (CodeODP) OTLookup(theOID);
- if (IsNULL(theCodeODP) || IsNULL(theCodeODP->dataPtr)) {
- /* Rats, we do not have the code -- delay the translation. */
- if (IsNULL(theCodeODP)) {
- /* Create one */
- theCodeODP =
- CreateCodeODEntry
- (theOID, mMakeLocation((*fHandlePtr)->mmMsgHdr.MsgSrc,1));
- }
-
- /*
- * Note: no load request for the code since one is
- * generated by the moved object.
- *
- * Put a translation record into the map.
- */
-
- KMDTrace("TT", 4,
- "TT: TRec for code addr 0x%08x, OID %s, offset %d\n",
- t->TT.CA.oldODP, PPCOID(theOID), theOffset);
- tRec = (TRecPtr) malloc(sizeof(TRec));
- tRec->theOID = theOID;
- tRec->theOffset = theOffset;
- /*
- * The fact that we do not have the address is
- * indicated by inserting the record pointer negated.
- * (OK, so it is a hack).
- */
- Map_Insert(fTMap, (int) t->TT.CA.oldODP, - (int) tRec);
- break;
- }
- newAddr = (CodeAddr) addOffset(theCodeODP->dataPtr, theOffset);
- KMDTrace("TT", 4, "TT: Code Addr 0x%06x -> 0x%06x offset %d in %s\n",
- t->TT.CA.oldODP, newAddr, theOffset,
- PPCodePtr(theCodeODP->dataPtr));
- Map_Insert(fTMap, (int) t->TT.CA.oldODP, (int) newAddr);
- }
- break;
- }
- }
-
- case TTMoveSSODITag: {
- if(isRecovery){
- ErrMsg("Should never get a TTMoveSSODITag in RecoverDigestTable #2!");
- abort();
- } else {
- register TTMoveSSODEntry *s;
- SSODP theSSODP;
- SSPtr p;
- int sizeOfStack;
- Offset delta;
- SSAddr newAddr;
-
- /*
- * Read rest of SSOD info
- * Allocate and fill in SSOD and SS
- * read in stack
- * insert stack info
- */
- length = sizeof(TTMoveSSODEntry) - sizeof(TTGenericEntry);
- LMGetData(fHandlePtr, addOffset(t, sizeof(TTGenericEntry)), &length);
- s = &t->TT.MSS;
- theSSODP = (SSODP) OTLookup(s->ownOID);
- if (IsNULL(theSSODP)) {
- p = NewStackSegment(s->thisSegmentSize);
- theSSODP = p->ownSSODP;
- theSSODP->ownOID = s->ownOID;
- theSSODP->ownLoc = NewLocation(s->ownLoc, GetLNN());
- theSSODP->processOID= s->processOID;
- theSSODP->tag.isResident = TRUE;
- OTInsert((ODP) theSSODP);
- } else {
- SSODP newSSODP;
- EmLocation theNewLocation;
- NodeNum myLNN = GetLNN();
-
- theNewLocation = NewLocation(s->ownLoc, myLNN);
- UpdateLocation(s->ownOID, theNewLocation, myLNN);
-
- /*
- * Boy is this dumb, we already have an OD and have to
- * discard the new one.
- */
- KMDTrace("FixMe", 5, "FixMe: use better OD alloc in DigestSSOD\n");
- p = NewStackSegment(s->thisSegmentSize);
- newSSODP = p->ownSSODP;
- theSSODP->dataPtr = p;
- p->ownSSODP = theSSODP;
- emfree((char *)newSSODP);
- }
- /* assert(theSSODP points to an SS of appropriate size) */
- theSSODP->tag.isResident= TRUE;
- theSSODP->tag.frozen = TRUE;
- p->availStack = s->availStack;
- p->processOID = s->processOID;
- p->ownOID = s->ownOID;
- p->regs = s->regs;
- p->resultBrand = s->resultBrand;
- p->readyQLink = s->oldReadyQLink;
- p->rPtr = s->rPtr;
- p->invokePtr = s->invokePtr;
- p->status = s->status;
- KMDTrace("Move", 3,
- "Stack Segment %s moved here, Process %s status %s\n",
- PPOID(p->ownOID), PPPOID(p->processOID),
- PPSSRunStatus((int)p->status.rs));
- /*
- * The rest of the item is a variable sized stack area.
- * Compute size and relocation addressing.
- */
- sizeOfStack = t->TT.MSS.hdr.size - sizeof(TTMoveSSODEntry);
- KMDTrace("FixMe", 4, "(FixMe: PORTABILITY:Stacks grow high->low\n)");
- /* PORTABILITY:
- * Stacks grow from high addresses toward low addresses.
- */
-
- /* Offset from high end of area since stacks grow down */
- newAddr = (SSAddr) addOffset(p->endOfSS, -sizeOfStack);
- delta = (Offset) byteOffset(s->oldSSPtr, newAddr);
-
- KMDTrace("Move", 5, "SS old SSPtr 0x%06x newSS 0x%06x delta 0x%06x\n",
- s->oldSSPtr, p, delta);
- KMDTrace("Move", 5, "sp 0x%06x -> 0x%06x size %d endOfSS 0x%06x\n",
- s->regs.sp, newAddr, sizeOfStack, p->endOfSS);
-
- length = sizeOfStack;
- LMGetData(fHandlePtr, newAddr, &length);
- assert(length == sizeOfStack);
-
- /* Insert SS and its current sp into translation map */
- Map_Insert(fTMap, (int) s->oldSSPtr, (int) p);
- Map_Insert(fTMap, (int) p->regs.sp, (int) newAddr);
-
- /* Insert SS into map of newly arrived objects */
- Set_Insert(fNewSet, (int) p);
-
- break;
- }
- }
-
- case TTInvokeITag: {
- register InvokeReqPtr req;
- length = sizeof(TTInvokeReqEntry) - sizeof(TTGenericEntry);
- GETDATA(fHandlePtr, addOffset(t, sizeof(TTGenericEntry)),&length);
- assert (length==sizeof(TTInvokeReqEntry)-sizeof(TTGenericEntry));
- req = mNewRequest(Invoke);
- req->i.callerSSOID = t->TT.IR.callerSSOID;
- req->i.callerLoc = t->TT.IR.callerLoc;
- req->i.argumentCount = t->TT.IR.argumentCount;
- req->i.resultCount = t->TT.IR.resultCount;
- req->i.processOID = t->TT.IR.processOID;
- req->i.targetOID = t->TT.IR.targetOID;
- req->i.targetTryAtLoc = t->TT.IR.targetTryAtLoc;
- req->m = (Map) NULL;
- req->neededMap = (Map) NULL;
- req->newSet = (Set) NULL;
-
- Map_Insert(fTMap, (int) t->TT.IR.oldODP, (int) req);
-
- /* Note, that req get translated when the SS that they are req for
- * are translated and thus reqs are NOT entered into the fNewSet
- * (they could not be in it anyway since they do not have ODTags)
- */
- KMDTrace("TT", 4, "TT: InvokeReq %s target %s\n",
- PPPOID(req->i.processOID), PPGOID(req->i.targetOID));
- KMDTrace("TT", 5, " %d arg%s %d result%s\n",
- req->i.argumentCount, mPLURAL(req->i.argumentCount),
- req->i.resultCount, mPLURAL(req->i.resultCount));
- break;
- }
-
- case TTIncomingIITag: {
- register IncomingIReqPtr req;
- length = sizeof(TTIncomingIReqEntry) - sizeof(TTGenericEntry);
- GETDATA(fHandlePtr, addOffset(t, sizeof(TTGenericEntry)),&length);
- assert(length==sizeof(TTIncomingIReqEntry)-sizeof(TTGenericEntry));
- req = mNewRequest(IncomingI);
- req->status = IHCodeLoadDone;
- req->i.callerSSOID = t->TT.IIR.callerSSOID;
- req->i.callerLoc = t->TT.IIR.callerLoc;
- req->i.argumentCount = t->TT.IIR.argumentCount;
- req->i.resultCount = t->TT.IIR.resultCount;
- req->i.processOID = t->TT.IIR.processOID;
- req->i.targetOID = t->TT.IIR.targetOID;
- req->i.targetTryAtLoc = t->TT.IIR.targetTryAtLoc;
- req->i.stackAvailable = NIL;
-
- req->opNumber = -1;
- req->visitorSet = (Set) NULL;
-
- Map_Insert(fTMap, (int) t->TT.IIR.oldODP, (int) req);
-
- /* Note, that req get translated when the SS that they are req for
- * are translated and thus reqs are NOT entered into the fNewSet
- * (they could not be in it anyway since they do not have ODTags)
- */
- KMDTrace("TT", 4, "TT: IncomingIReq %s target %s\n",
- PPPOID(req->i.processOID), PPGOID(req->i.targetOID));
- KMDTrace("TT", 5, " %d arg%s %d result%s\n",
- req->i.argumentCount, mPLURAL(req->i.argumentCount),
- req->i.resultCount, mPLURAL(req->i.resultCount));
- break;
- }
-
- case TTCondITag: {
- /* Get rest of CondEntry */
- length = sizeof(TTCondEntry) - sizeof(TTGenericEntry);
- GETDATA(fHandlePtr, addOffset(t, sizeof(TTGenericEntry)), &length);
- entry = OTLookup(t->TT.CD.ownOID);
- if (IsNULL(entry)) {
- /* Insert a new entry */
- entry = getFreeOD();
- entry->CD.ownOID = t->TT.CD.ownOID;
- entry->CD.tag = t->TT.CD.tag;
- entry->CD.tag.frozen = TRUE;
- entry->CD.tag.isResident = FALSE;
- entry->CD.ownLoc = t->TT.CD.ownLoc;
- entry->CD.theLock = (MonitorLockPtr) EMNIL;
- entry->CD.ARListHead.next = entry->CD.ARListHead.prev =
- (InvokeQueuePtr) &entry->CD.ARListHead;
- entry->CD.waiting = (SSPtr) NULL;
- OTInsert(entry);
- } else {
- assert (entry->CD.tag.tag == t->TT.CD.tag.tag);
- /* Check to see if location timestamp is newer */
- if (entry->G.ownLoc < t->TT.FGOD.ownLoc) {
- KMDTrace("TT", 3, "Cond OID %s was @ 0x%04x now @ 0x%04x\n",
- PPOID(entry->CD.ownOID), entry->CD.ownLoc, t->TT.CD.ownLoc);
- entry->CD.ownLoc = t->TT.CD.ownLoc;
- KMDTrace("FixMe", 5, "Fix me: should reset ODTag flags.\n");
- }
- }
- Map_Insert(fTMap, (int) t->TT.CD.oldODP, (int) entry);
- KMDTrace("TT", 4, "TT Cond %s %-9.9s@%s (0x%05x -> 0x%05x)\n",
- PPOID(t->TT.CD.ownOID), PPODBasicTag(t->TT.CD.tag.tag),
- PPLoc(t->TT.CD.ownLoc), t->TT.CD.oldODP, entry);
- break;
- }
-
- case TTFetchGODITag: {
- /* Get rest of FetchGODEntry */
- length = sizeof(TTFetchGODEntry) - sizeof(TTGenericEntry);
- GETDATA(fHandlePtr, addOffset(t, sizeof(TTGenericEntry)),&length);
- entry = OTLookup(t->TT.FGOD.ownOID);
- if (IsNULL(entry)) {
- /* Insert a new entry */
- entry = getFreeOD();
- entry->G.ownOID = t->TT.FGOD.ownOID;
- entry->G.tag = t->TT.FGOD.tag;
- entry->G.tag.frozen = TRUE;
- entry->G.tag.isResident = FALSE;
- entry->G.ownLoc = t->TT.FGOD.ownLoc;
- entry->G.ARListHead.next = entry->G.ARListHead.prev =
- (InvokeQueuePtr) &entry->G.ARListHead;
- entry->G.myCodeOID = t->TT.FGOD.myCodeOID;
- /* Lookup and insert code, if necessary */
- codeEntry = (CodeODP) OTLookup(t->TT.FGOD.myCodeOID);
- if (IsNULL(codeEntry)) { /* Create an entry */
- codeEntry= CreateCodeODEntry(t->TT.FGOD.myCodeOID,t->TT.FGOD.ownLoc);
- } else { /* Verify that it is a code entry */
- assert(codeEntry->tag.tag == CodeODTag);
- }
- OTInsert(entry);
- } else {
- assert (entry->G.tag.tag == t->TT.FGOD.tag.tag);
- /* Check to see if location timestamp is newer */
- if (LOCATIONNEWER(t->TT.FGOD.ownLoc, entry->G.ownLoc)) {
- KMDTrace("TT", 3, "GO OID 0x%05x was @ 0x%04x now @ 0x%04x\n",
- entry->G.ownOID, entry->G.ownLoc, t->TT.FGOD.ownLoc);
- entry->G.ownLoc = t->TT.FGOD.ownLoc;
- KMDTrace("FixMe", 5, "Fix me: should reset ODTag flags.\n");
- }
- }
- Map_Insert(fTMap, (int) t->TT.FGOD.oldODP, (int) entry);
- KMDTrace("TT", 4,
- "TTFetchGOD %#04x %-9.9s@0x%04x (0x%05x)->(0x%05x) CT 0x%05x\n",
- t->TT.FGOD.ownOID, BasicTagName[(int) t->TT.FGOD.tag.tag],
- t->TT.FGOD.ownLoc, t->TT.FGOD.oldODP, entry,
- t->TT.FGOD.myCodeOID);
- break;
- }
-
- case TTMoveCondITag: {
- register CondODP theCondODP;
- /* Get rest of entry */
- length = sizeof(TTMoveCondEntry) - sizeof(TTGenericEntry);
- GETDATA(fHandlePtr, addOffset(t, sizeof(TTGenericEntry)),&length);
- assert(length == sizeof(TTMoveCondEntry)-sizeof(TTGenericEntry));
- theCondODP = (CondODP) OTLookup(t->TT.MCD.ownOID);
- if (IsNULL(theCondODP)) {
- /* Insert a new entry */
- theCondODP = (CondODP) getFreeOD();
- theCondODP->ownOID = t->TT.MCD.ownOID;
- theCondODP->tag = t->TT.MCD.tag;
- theCondODP->ownLoc = t->TT.MCD.ownLoc;
- theCondODP->ARListHead.next = theCondODP->ARListHead.prev =
- (InvokeQueuePtr) &theCondODP->ARListHead;
- theCondODP->dataPtr = (GODataPtr) NULL;
- OTInsert((ODP) theCondODP);
- }
- theCondODP->tag.isResident = TRUE;
- theCondODP->tag.frozen = TRUE;
- theCondODP->theLock = t->TT.MCD.theLock;
- theCondODP->waiting = (isRecovery?NULL:t->TT.MCD.theWaiting);
- theCondODP->ownLoc = NewLocation(theCondODP->ownLoc,GetLNN());
-
- /*
- * Insert into translation map.
- */
- Map_Insert(fTMap, (int) t->TT.MCD.oldODP, (int) theCondODP);
-
- /*
- * Insert into map of arrived objects that need translating.
- */
- Set_Insert(fNewSet, (int) theCondODP);
-
- KMDTrace("TT", 4, "TT: MoveCond (0x%06x -> 0x%06x) %s\n",
- t->TT.MCD.oldODP, theCondODP, PPOID(theCondODP->ownOID));
-
- KMDTrace((isRecovery?"Recover":"Move"), 3,
- "Condition (%s) moved here (%s)\n",
- PPOID(theCondODP->ownOID), PPLoc(theCondODP->ownLoc));
- break;
- }
-
- default: {
- ErrMsg("Cannot Digest item tag %s\n", PPITag(t->TT.GO.hdr.itemTag));
- abort();
- }
- }
-
- /* Get the Item hdr and the OD tag of the next translate item. */
- length = sizeof(TTGenericEntry);
- GETDATA(fHandlePtr, t, &length);
- }
-
- /*
- * The TTable information has now been digested. The loop
- * terminated either because there was no more data or because
- * a different item was found in which case the position must be
- * moved back.
- */
-
- if (length > 0) {
- /* Reset position so the other item may be reread */
- SEEKDATA(fHandlePtr, (long) -length, (long) 1);
- }
- }
-
-
-
- /*
- * TranslateReq
- *
- * Translate the given request data structure using the fTMap;
- * the reference itself is also translated and returned.
- * If a SS is associated with the Req then the fSSPtr given is
- * used to set the appropriate field.
- */
- GenericReqPtr TranslateReq(fReq, fTMap, fSSPtr)
- GenericReqPtr fReq;
- Map fTMap;
- SSPtr fSSPtr;
- {
- GenericReqPtr newReq;
-
- newReq = (GenericReqPtr) Map_Lookup(fTMap, (int) fReq);
-
- KMDTrace("TT", 3, "Translating Request (0x%06x -> 0x%06x) %s\n",
- fReq, newReq, PPRTag(newReq->hdr.rTag));
-
- switch (newReq->hdr.rTag) {
-
- case InvokeRTag: {
- register InvokeReqPtr req = (InvokeReqPtr) newReq;
-
- req->requestor = fSSPtr;
- req->targetGODP = (GODP) OTLookup(req->i.targetOID);
- assert(NonNULL(req->targetGODP));
- req->theAbConPtr= (AbConPtr) NULL; /* Irrelevant */
- break;
- }
-
- case IncomingIRTag: {
- register IncomingIReqPtr req = (IncomingIReqPtr) newReq;
- req->theProcess = fSSPtr;
- break;
- }
- }
- return newReq;
- }
-
-
-
- /*
- * TranslateCodeAddr
- */
- CodeAddr TranslateCodeAddr(fTMap, fOldAddr)
- Map fTMap;
- CodeAddr fOldAddr;
- {
- CodeAddr newAddr;
- CodeODP theCodeODP;
- TRecPtr theTRec;
-
- newAddr = (CodeAddr) Map_Lookup(fTMap, (int) fOldAddr);
- if (IsNIL(newAddr)) {
- ErrMsg("Translation error, addr 0x%08x unknown\n", newAddr);
- abort();
- }
- if (( (int) newAddr) < 0) {
- /* The code was not loaded when the address arrived but it should be
- * here now.
- */
- theTRec = (TRecPtr) (- ((int) newAddr)); /* HACK */
- theCodeODP = (CodeODP) OTLookup(theTRec->theOID);
- assert(NonNULL(theCodeODP));
- newAddr = (CodeAddr) addOffset(theCodeODP->dataPtr, theTRec->theOffset);
- KMDTrace("TT", 3,
- "TT: redo codeaddr (0x%06x -> 0x%06x) offset %d in %s, line %s\n",
- fOldAddr, newAddr, theTRec->theOffset,
- PPCodePtr(theCodeODP->dataPtr),
- PPFindLineNo(theCodeODP->dataPtr, newAddr));
- Map_Insert(fTMap, (int) fOldAddr, (int) newAddr);
- free((char *)theTRec);
- }
-
- KMDTrace("TT", 4, "TT: code addr (0x%06x -> 0x%06x)\n", fOldAddr, newAddr);
- return newAddr;
- }
-
- /************************************************************************/
- /************************************************************************/
-
- /*
- * ShoutOrSearchTimeOut
- */
- void ShoutOrSearchTimeOut(fOID, fTimerId, whichOne)
- OID fOID;
- int fTimerId;
- LocateStatus whichOne;
- {
- register LocateReqPtr req;
-
- KMDTrace("Locate", 4, (whichOne==Shouting ? "Shout" : "Search"));
- KMDTrace("Locate", 4, "TimeOut for %s; start searching\n", PPOID(fOID));
- req = (LocateReqPtr) Map_Lookup(LocateMap, (int) fOID);
- if (IsNIL(req)) {
- KMDTrace("Locate",4,
- whichOne == Shouting ?
- "ShoutTimeOut: %s - request already gone\n" :
- "SearchTimeOut: %s has already been found.\n",
- PPOID(fOID));
- return;
- }
- if (req->timerId != fTimerId) {
- KMDTrace("Locate", 4,
- whichOne == Shouting ?
- "ShoutTimeOut for %s - request long gone\n":
- "Already done (new req found).\n",
- PPOID(fOID));
- }
- if (req->status == Shouting) {
- KMDTrace("Locate", 3, "%s: try searching\n", PPOID(fOID));
- StartSearching(req);
- } else if(req->status == Searching){
- /*
- * One or more nodes has not responded to a search broadcast --
- * prod them using point to point messages.
- */
- KMDTrace("Loacte", 3, "Prodding nodes\n");
- CheckForProd(req);
- }
- }
-
- HResult ShoutTimeOut(fOID, fTimerId)
- OID fOID;
- int fTimerId;
- {
- ShoutOrSearchTimeOut(fOID, fTimerId, Shouting);
- }
-
- HResult SearchTimeOut(fOID, fTimerId)
- OID fOID;
- int fTimerId;
- {
- ShoutOrSearchTimeOut(fOID, fTimerId, Searching);
- }
-
-
-
- /*
- * LocationDeamon
- *
- * Scheduled to run when there are outstanding shout or search requests
- * Does the actual sending of location requests
- */
- HResult LocationDeamon()
- {
- LMHandle myHandle;
- LocateItem item;
- LocateInfo info;
- register int i;
-
- KMDTrace("Locate", 4, "Locate Deamon activated\n");
-
- if (searchList->count > 0) {
- /* Work to do */
- KMDTrace("Locate", 3, "Locate Deamon broadcast search for %d object\n",
- searchList->count);
- LMStartMsg(&myHandle, KMSG_EmKernel, EMKM_Item, NULL);
-
- /* Put stuff into the msg */
- item.hdr.itemTag = SearchITag;
- item.hdr.size = searchList->count * sizeof(info) + sizeof(item.hdr);
- LMPutData(&myHandle, &item, sizeof(item.hdr));
-
- KMDTrace("FixMe", 4, "Search list: Fix handling of overflow\n");
- assert(searchList->count < 200);
- for (i = 0; i < searchList->count; i++) {
- info.theOID = (OID) searchList->array[i];
- info.theLocation = (EmLocation) NULL;
- LMPutData(&myHandle, &info, sizeof(info));
- }
- cLOC_SearchsSent += searchList->count;
- cLOC_SearchBroadcastsSent++;
-
- (void) LMBroadcastMsg(&myHandle);
- DynClear(searchList);
- }
-
- if (shoutList->count > 0) {
- /* Work to do */
- KMDTrace("Locate", 3, "Locate Deamon broadcast shout for %d object\n",
- shoutList->count);
- LMStartMsg(&myHandle, KMSG_EmKernel, EMKM_Item, NULL);
-
- /* Put stuff into the msg */
- item.hdr.itemTag = ShoutITag;
- item.hdr.size = shoutList->count * sizeof(info) + sizeof(item.hdr);
- LMPutData(&myHandle, &item, sizeof(item.hdr));
-
- KMDTrace("FixMe", 3, "Search list overflow is not handled\n");
- assert(shoutList->count < 200);
- for (i = 0; i < shoutList->count; i++) {
- info.theOID = (OID) shoutList->array[i];
- info.theLocation = (EmLocation) NULL;
- LMPutData(&myHandle, &info, sizeof(info));
- }
- cLOC_ShoutsSent += shoutList->count;
- cLOC_ShoutBroadcastsSent++;
-
- (void) LMBroadcastMsg(&myHandle);
- DynClear(shoutList);
- }
- LocationDeamonRunning = FALSE;
- }
-
-
- /*
- * Schedule the Locate Deamon if it is not already running
- */
- void EnsureLocationDeamon()
- {
- if (!LocationDeamonRunning) {
- KMDTrace("Locate", 5, "Scheduling Location Deamon\n");
- LocationDeamonRunning = TRUE;
- (void) MMSetMicroTimer((int)(vLOCDeamonInterval/1000000),
- (int)(vLOCDeamonInterval % 1000000),
- (HandlerPtr)LocationDeamon, NULL, (TimerId *)NULL);
- }
- }
-
- /************************************************************************/
- /************************************************************************/
-
- void LocateInit()
- {
- int bits, i, theAddr, theOpNumber;
-
- KMDTrace("FixMe", 5, "Consider checking result of LMBroadcastMsg\n");
-
- KMDSetTrace(OT);
- KMDSetTrace(TT);
- KMDSetTrace(Locate);
-
- KMDTrace("Locate", 4, "LocateInit, initial OT size %d\n", INITIALOTSIZE);
- KMDTrace("OT", 4, "LocateInit, initial OT size %d\n", INITIALOTSIZE);
-
- KMDSetSnap(OTDump);
- KMDSetSnap(OTDataDump);
- KMDSetSnap(LOCLocateMap);
- KMDSetSnap(EmDataDump);
- KMDSetSnap(EmCTRefDump);
-
- /* Allocate Object table */
- OTSize = INITIALOTSIZE;
- OTMask = OTSize - 1;
- /* Check for OTSize power of 2 by counting bits */
- for (bits = 0, i = OTSize; i != 0 ; i >>= 1) if (i & 01) bits++;
- if (bits != 1) {
- ErrMsg("Error: Hash table size not power of 2 ***\n");
- ErrMsg(" Was %d\n", OTSize);
- for (bits = 0, i = OTSize; i != 0 ; i>>=1, bits++);
- OTSize = 1 << bits;
- ErrMsg(" Changed to %d\n", OTSize);
- OTMask = OTSize -1;
- }
- OTLimit = OTSize - (OTSize >> 3) - 1; /* Fill no more than 87.5% */
- CreateArray((int **)&OT, OTSize * sizeof(ODP));
- KMDTrace("FixMe", 5, "The following assumes that NULL is 0\n");
- assert(NULL == 0);
- bzero((char *) (&OT[0]), OTSize * sizeof(ODP));
- nOT = 0;
-
- /* Preinitialize structures for AddToTTable */
- godEntry.hdr.itemTag = TTGODITag;
- godEntry.hdr.size = sizeof(godEntry);
- condEntry.hdr.itemTag = TTCondITag;
- condEntry.hdr.size = sizeof(condEntry);
- ssodEntry.hdr.itemTag = TTSSODITag;
- ssodEntry.hdr.size = sizeof(ssodEntry);
- abconEntry.hdr.itemTag = TTAbConITag;
- abconEntry.hdr.size = sizeof(abconEntry);
- codeodEntry.hdr.itemTag = TTCodeODITag;
- codeodEntry.hdr.size = sizeof(codeodEntry);
- loEntry.hdr.itemTag = TTLOITag;
- loEntry.hdr.size = sizeof(loEntry);
- movegodEntry.hdr.itemTag = TTMoveGODITag;
- movegodEntry.hdr.size = sizeof(movegodEntry);
- movecodeodEntry.hdr.itemTag = TTMoveCITag;
- movecodeodEntry.hdr.size = sizeof(movecodeodEntry);
- fetchgodEntry.hdr.itemTag = TTFetchGODITag;
- fetchgodEntry.hdr.size = sizeof(fetchgodEntry);
- codeaddrEntry.hdr.itemTag = TTCodeAddrITag;
- codeaddrEntry.hdr.size = sizeof(codeaddrEntry);
- moveCondEntry.hdr.itemTag = TTMoveCondITag;
- moveCondEntry.hdr.size = sizeof(TTMoveCondEntry);
-
- SetItemHandler(ConfirmITag, ConfirmItemHandler);
- SetItemHandler(ShoutITag, ShoutItemHandler);
- SetItemHandler(SearchITag, SearchItemHandler);
- SetItemHandler(ConfirmReplyITag, ConfirmReplyItemHandler);
- SetItemHandler(ShoutReplyITag, ShoutReplyItemHandler);
- SetItemHandler(SearchReplyITag, SearchReplyItemHandler);
-
- LocateMap = Map_Create();
- KernelReturnAddressMap = Map_Create();
- Map_Insert(KernelReturnAddressMap, (int) &ReturnOffStack, 1);
-
- /* Now invert the KernelReturnAddressMap */
- KernelReturnOpNumberMap = Map_Create();
- Map_For(KernelReturnAddressMap, theAddr, theOpNumber);
- KMDTrace("TT", 5, "Kernel op #%d\taddr: 0x%06x\n", theOpNumber, theAddr);
- Map_Insert(KernelReturnOpNumberMap, theOpNumber, theAddr);
- Map_Next;
-
- LocationDeamonRunning = FALSE;
- #define INITIALLISTCOUNT 20
- shoutList = DynCreate(INITIALLISTCOUNT);
- searchList = DynCreate(INITIALLISTCOUNT);
- listlength = INITIALLISTCOUNT * sizeof(LocateInfo);
- CreateArray((int **)&list, listlength);
- }
-
- /**********************************************************************/
- /* Snapshots */
- /**********************************************************************/
-
- /**********************************************************************/
- /* LOCLocateMap */
- /**********************************************************************/
-
- /*Snapshot*/
- void LOCLocateMap(fOID)
- int fOID;
- {
- LocateReqPtr req;
- int theOID;
-
- KMDPrint("LocateMap dump for node #%d\n", GetLNN());
- if (Map_Count(LocateMap) == 0) {
- KMDPrint("No outstanding location requests.\n");
- return;
- }
- KMDPrint("OID \t\tLoc. hint\tStatus\n");
- Map_For(LocateMap, theOID, req)
- if (NonNULL(fOID) && req->theOID == fOID) continue;
- KMDPrint("0x%08x\t0x04x\t%s\n", req->theOID,
- req->status == Waiting ? "Waiting for previous locate" :
- req->status == WaitingForCodeLoad ? "Located; being loaded" :
- req->status == Confirming ? "Confirming location hint" :
- req->status == Shouting ? "Broadcast in progress" :
- req->status == Searching ? "Searching; waiting for replies":
- "BAD STATUS");
- if (req->waiting)
- KMDPrint("\t\t\t%s in %s\n",
- PPPOID(req->waiting->processOID), PPSSPlace(req->waiting));
- Map_Next
- }
-
-
-
- /**********************************************************************/
- /* Snapshot subroutine */
- /* Prints an object table entry.*/
- void snapOD(entry)
- ODP entry;
- {
- /* ODP first, p; */
-
- KMDPrint("OD (#%06x) OID: 0x%05x, ODTag: %s\n", entry, entry->G.ownOID,
- PPODTag(entry->G.tag));
-
- /*
- KMDPrint("Location LNN %d, %s %s %s\n", (int) entry->G.ownLoc,
- entry->G.setUpDone ? "Fully instantiated" : "Being initialized",
- entry->G.IsResident ? "Is resident" : "Non-resident");
- first = entry->G.ARListHead;
- if (first != (ODP) NULL) {
- char buf[1000], buf2[1000];
- (void) sprintf(buf, "Active frames: ");
- p = first;
- do {
- (void) sprintf(buf2, " 0x%01x", p->ownOID);
- (void) strcat(buf, buf2);
- p = getNextAR(p);
- } while (p != first);
- KMDPrint("%-.72s\n", buf);
- }
- */
- }
-
- /* Snapshot to dump an OT entry or the entire OT (in hash order) */
- void OTDump(fIndex)
- int fIndex;
- {
- register SSPtr ssp;
- register int index;
- time_t theTime = time((time_t *) 0);
- char buf[1000], buf2[1000];
-
- KMDPrint("Object Table dump node %d %s\n", GetLNN(), ctime(&theTime));
- if (NonNULL(currentSSP)) {
- KMDPrint( "Running : 0x%04x\n", currentSSP->processOID);
- }
- if (NonNULL(readyQ)) {
- (void) sprintf(buf, "Ready Queue: ");
- ssp = getRQLink(readyQ);
- do {
- (void) sprintf(buf2, " 0x%01x", ssp->processOID);
- (void) strcat(buf, buf2);
- ssp = getRQLink(ssp);
- } while (ssp != readyQ);
- KMDPrint("%-.70s\n", buf);
- } else KMDPrint("Ready queue empty\n");
- if (fIndex == 0) {
- /* Full object table dump */
- for (index = 0; index < OTSize; index++) {
- if (OT[index]) snapOD(OT[index]);
- }
- } else KMDPrint("Index out of range.\n");
- }
-
-
-
- /*
- * snapData
- *
- * Prints a data area or OD. Called from snapshot operations.
- */
- void snapData(fEntry)
- ODP fEntry;
- {
- KMDPrint("ODBasicTag : %s\n", PPODTag(fEntry->G.tag));
-
- #ifdef OBSOLETE
- KMDPrint("ODBasicTag : %s %s%s%s%s%s%s%s%s%s%s%c%c%s%s%s%s\n",
- BasicTagName[(int) fEntry->G.tag.tag],
- (fEntry->G.tag.global ? "Global " : ""),
- (fEntry->G.tag.replicated ? "Repl " : ""),
- (fEntry->G.tag.frozen ? "Frozen " : ""),
- (fEntry->G.tag.isResident ? "Resident " : "Remote "),
- (fEntry->G.tag.setUpDone ? "" : "Init "),
- (fEntry->G.tag.isFixed ? "Fixed " : ""),
- (fEntry->G.tag.inTransit ? "migrating " : ""),
- (fEntry->G.tag.allInstancesAreLocal ? "allLocal ": ""),
- (fEntry->G.tag.hasNoPointer ? "No ptr " : ""),
- (fEntry->G.tag.gcFrozen ? "gcFz " : ""),
- (fEntry->G.tag.gcMark1 ? '1' : ' '),
- (fEntry->G.tag.gcMark2 ? '2' : ' '),
- (fEntry->G.tag.xref ? "externally referenced " : ""),
- (fEntry->G.tag.localgcMark1 ? "l1" : " "),
- (fEntry->G.tag.localgcMark2 ? "l2" : " "),
- (fEntry->G.tag.otherstuff == OBSCUREVALUE) ? "" : " ** TRASHED **");
- #endif OBSOLETE
-
- switch (fEntry->G.tag.tag) {
-
- case GODTag: {
- register InvokeQueuePtr q, head;
-
- KMDPrint("GOD %s @ 0x%04x dataPtr 0x%06x, code: %s\n",
- PPGOID(fEntry->G.ownOID),
- fEntry->G.ownLoc, fEntry->G.dataPtr, PPCOID(fEntry->G.myCodeOID));
- if (!fEntry->G.tag.isResident) break;
-
- /* Dump invoke queue list */
- head = &fEntry->G.ARListHead;
- for (q = head->next; q != head; q = q->next) {
- KMDPrint("\tAR (0x%06x)\tProcess %s\n",
- addOffset(q, sizeof(InvokeQueue) + LOFFSETFROMDYNAMICLINK),
- PPPOID(((SSPtr) (-(int)(q->mySSPtr)))->processOID));
- }
- break;
- }
-
- case LOTag:
- case GODataTag: {
- register TemplateEntryPtr t;
- register int i;
- register Bytes *dataAddr;
- CodePtr cPtr;
- TemplatePtr theTemplate;
-
- cPtr = fEntry->L.myCodePtr;
- assert(NonNULL(cPtr));
- KMDPrint("Instance size: %d\t\tone of %s\n", cPtr->instanceSize,
- PPCodePtr(cPtr));
- if (!cPtr->ODATemplateOffset) break;
- theTemplate = (TemplatePtr) addOffset(cPtr, cPtr->ODATemplateOffset);
- KMDPrint("Number of template entries %d\n",
- theTemplate->B.numEntries);
-
- t = &theTemplate->entry[0];
- if (fEntry->L.tag.replicated) {
- dataAddr = (Bytes *) &fEntry->R.inlineData[0];
- } else dataAddr = (Bytes *) &fEntry->L.inlineData[0];
-
- /*KMDPrint("Data starts at 0x%05x\n", dataAddr);*/
- for (i = 0; i < theTemplate->B.numEntries; i++) {
-
- switch (t->TE.SS.Format) {
- /*
- case ShortDynamicF:
- KMDPrint("\tShortDynamicF\t(%s), data = %d, code = %d\n",
- BrandNames[(int)t->TE.SD.theBrand], t->TE.SD.dataOffset,
- t->TE.SD.codeOffset);
- KMDPrint("Fix me: no dynamics in data areas\n");
- break;
-
- case LongDynamicF: {
- LongDynamic *ld;
- ld = (LongDynamic *) t;
- KMDPrint("\tLongDynamicF\t(%s), data = %d, code = %d\n",
- BrandNames[(int)ld->theBrand], ld->dataOffset,
- ld->codeOffset);
- i++;
- KMDPrint("Fix me: no dynamics in data areas\n");
- break;
- }
- */
- case ShortStaticF: {
- KMDPrint(
- "\tShortStaticF\t(%s) %s\tcount =%4d\n",
- BrandNames[(int)t->TE.SS.theBrand],
- t->TE.SS.paramInfo != 0 ? "isParam" : " ",
- t->TE.SS.count);
-
- switch (t->TE.SS.theBrand) {
-
- case DataBrand: {
- register int j;
- for (j = 0; j < t->TE.SS.count; j+=sizeof(int)) {
- KMDPrint("%6d: Data: %08x\n",
- (dataAddr + j) - (Bytes *) fEntry,
- * ((int *)(dataAddr + j)));
- }
- dataAddr += t->TE.SS.count;
- break;
- }
-
- case ODPBrand: {
- register int j;
- for (j = 1; j <= t->TE.SS.count; j++) {
- KMDPrint("%6d: ODP (0x%05x)\n",
- dataAddr - (Bytes *) fEntry,
- * ((int *) dataAddr));
- }
- dataAddr += sizeof(ODP) * t->TE.SS.count;
- break;
- }
-
- case AddrBrand:{
- assert(t->TE.SS.theBrand != AddrBrand);
- dataAddr += t->TE.SS.count * sizeof(dataAddr);
- break;
- }
-
- case VectorBrand: {
- register VectorAreaPtr v;
- register int count;
-
- v = (VectorAreaPtr) dataAddr;
- dataAddr = (Bytes *) &v->data[0];
- count = v->count;
-
- KMDPrint("\t\tElementBrand = %s, count %d\n",
- BrandNames[(int)t->TE.SS.elementBrand], count);
-
- switch (t->TE.SS.elementBrand) {
-
- case DataBrand: {
- if (fEntry->L.myCodePtr->ownOID == (unsigned int) 0xff00008b) {
- /* A real hack but for debug only */
- /* It is a string */
- KMDPrint("\t\tString: %.*s\n", count, &v->data[0]);
- } else KMDPrint("\t\tVector is data.\n");
- break;
- }
-
- case ODPBrand: {
- register ODP *ODPAddr = (ODP *) dataAddr;
- register int j;
- for (j = 0; j < count / sizeof(ODP); j++) {
- KMDPrint("\t\t%6d: ODP (0x%05x)%s\n",
- j, *ODPAddr,
- t->TE.SS.attachedFlag ? " Attached" : "");
- ODPAddr++;
- }
- break;
- }
-
- case AddrBrand:{
- assert(FALSE);
- abort();
- }
-
- case VariableBrand: {
- register int j;
- register AVariablePtr varPtr;
-
- for (j = 0; j < count / sizeof(AVariable); j++){
- varPtr = (AVariablePtr) dataAddr;
- if (IsNIL(varPtr->myAddr) ||
- IsNIL(varPtr->myAbConPtr)) {
- KMDPrint("\t\t%6d: Var (NIL, NIL)\n", j);
- dataAddr += sizeof(AVariable);
- continue;
- }
- KMDPrint("\t\t%6d: Var (0x%01x, 0x%01x), %s\n",
- j, varPtr->myAddr, varPtr->myAbConPtr, PPVar(varPtr));
- dataAddr += sizeof(AVariable);
- }
- break;
- }
-
- default: {
- ErrMsg("Bad element brand %s, in vector -- compiler error\n",
- PPBrand(t->TE.SS.elementBrand));
- abort();
- }
- } /* switch on Vector element brand*/
-
- break;
- } /* case Vector Brand */
-
- case VariableBrand: {
- register int j;
- register AVariablePtr varPtr;
-
- for (j = 1; j <= t->TE.SS.count; j++){
- varPtr = (AVariablePtr) dataAddr;
- KMDPrint("%6d: Variable (0x%04x, 0x%04x), %s\n",
- dataAddr - (Bytes *)fEntry,
- varPtr->myAddr, varPtr->myAbConPtr,
- PPVar(varPtr));
- dataAddr += sizeof(AVariable);
- }
- break;
- }
-
- case MonitorBrand: {
- register MonitorLockPtr mPtr;
- register SSPtr p;
-
- mPtr = (MonitorLockPtr) dataAddr;
- KMDPrint("%6d: Monitor %s\n", dataAddr - (Bytes *) fEntry,
- mPtr->isLocked ? "Locked" : "Open");
- /* for the following assert search for comments re
- * MONITOROFFSETWITHINOBJECT
- */
- assert(MONITOROFFSETWITHINOBJECT == byteOffset(fEntry, dataAddr));
- if (NonNULL(mPtr->waiting)) {
- KMDPrint("\tAwaiting entry:\n");
- p = getRQLink(mPtr->waiting);
- do {
- KMDPrint("\t\t%s in %s\n", PPPOID(p->processOID),
- PPSSPlace(p));
- p = getRQLink(p);
- } while (p != mPtr->waiting);
- }
- dataAddr += sizeof(MonitorLock);
- break;
- }
-
- default: {
- KMDPrint("Bad brand %s\n", PPBrand(t->TE.SS.theBrand));
- }
-
- } /* end switch */
-
- t = (TemplateEntryPtr) addOffset(t, sizeof(ShortStatic));
- break;
- }
-
- case RegisterF:
- KMDPrint("\tRegisterF\t(%s),\t%s, r%d, count %d\n",
- BrandNames[(int)t->TE.R.theBrand],
- t->TE.R.storedWhere == InRegister ? "InRegister"
- : "InSaveArea", t->TE.R.reg, t->TE.R.count);
- KMDPrint("Compiler Error (?): registers in data area ???\n");
- break;
-
- default:
- KMDPrint("Bad format %d\n", t->TE.SS.Format);
- assert(FALSE);
- break;
- }
- }
- break;
- }
-
- case SSODTag: {
- register SSODP myODP;
- myODP = (SSODP) fEntry;
-
- KMDPrint("SSOD @ 0x%04x OID: %s, process %s\n", myODP->ownLoc,
- PPOID(myODP->ownOID), PPPOID(myODP->processOID));
- break;
- }
-
- case SSTag: {
- CodePtr cPtr;
- register SSPtr p;
- register SSAddr sAddr;
- register SSAddr l;
- RegisterSave regs;
- CodeAddr ip = 0;
- GODP b;
- GODataPtr g;
- SSAddr sp;
- TemplatePtr tPtr;
- TemplateEntryPtr entry;
- AVariablePtr aVar;
- DynamicLinkPtr theLink;
- int i, tOffset, it, k, argumentCount, resultCount;
- IPMapPtr templateMap;
-
- p = (SSPtr) fEntry;
-
- if (IsNULL(p)) {
- KMDPrint("** NIL stack segment **\n");
- break;
- }
-
- KMDPrint("STACK SEGMENT \tProcess %s\n", PPPOID(p->processOID));
- KMDPrint("SSPtr 0x%05x\n", p);
- KMDPrint("Status:\t\t\t%s%s\n", PPSSRunStatus((int)p->status.rs),
- ((p->status.rs != SSNotInUse) && (mStoppedAtEntry(p))) ?
- " Stopped at Operation Entry" : "");
- KMDPrint("Segment Size: \t\t%4d\n", p->segmentSize);
- KMDPrint("Available: \t\t%4d\n", p->availStack);
- KMDPrint("sp limit \t\t0x%06x (stack top limit)\n", p->splimit);
- KMDPrint("sp \t\t0x%06x (stack top)\n", p->regs.sp);
- KMDPrint("bottom: \t\t0x%06x (highest address)\n", p->endOfSS);
-
- if (p->status.rs == SSNotInUse) {
- KMDPrint("Stack Segment is not in use; on Hot Standby queue\n");
- break;
- }
-
- sAddr = sp = p->regs.sp;
- if (!SSValidAddr(p, sp)) {
- KMDPrint("** Empty Stack **\n");
- break;
- } else {
- KMDPrint("Current sp:\t\t0x%06x (current address)\n", sp);
- }
- KMDPrint("splimit: \t\t0x%06x (low address)\n", p->splimit);
-
- ip = * (CodeAddr *) sp;
- l = p->regs.l;
- theLink = mDynLinkPtrFromL(l);
- b = p->regs.b;
- g = p->regs.g;
- regs = p->regs;
-
- while (NonNULL(l) && SSValidAddr(p, l)) {
- cPtr = g->myCodePtr;
- if (IsNULL(cPtr)) {
- KMDPrint("Bad code ptr for l = 0x%05x\n", l);
- break;
- }
-
- /* Print the current activation record */
- KMDPrint("\nActivation record at %s, line %s\n",
- PPCodePtr(cPtr), PPFindLineNo(cPtr, ip));
- KMDPrint("b = 0x%05x, g = 0x%05x, sp = 0x%05x, l = 0x%05x\n",
- b, g, sp, l);
- KMDPrint("ip offset: %d (0x%05x)\n", byteOffset(cPtr, ip),
- byteOffset(cPtr, ip));
- if (IsNULL(cPtr->templateMapOffset)) {
- KMDPrint("No template IPMap\n");
- break;
- }
- templateMap = (IPMapPtr) addOffset(cPtr, cPtr->templateMapOffset);
- tOffset = IPMapLookup(templateMap, byteOffset(cPtr, ip));
- if (IsNULL(tOffset)) {
- KMDPrint("No template for offset\n", byteOffset(cPtr, ip));
- break;
- }
- tPtr = (TemplatePtr) addOffset(cPtr, tOffset);
- KMDPrint("%d entr%s in template\n", tPtr->B.numEntries,
- mPLURALY(tPtr->B.numEntries));
-
- /* Traverse the template and find argument and result counts */
- entry = &tPtr->entry[0];
- argumentCount = resultCount = 0;
- for (k = 0; k < tPtr->B.numEntries; k++, entry++) {
- if ((entry->TE.SS.Format == ShortStaticF) &&
- (entry->TE.SS.paramInfo != IsNotParam)) {
- /* There are parameters */
- if (entry->TE.SS.paramInfo == IsArgument) {
- argumentCount += entry->TE.SS.count;
- } else resultCount += entry->TE.SS.count;
- } else {
- break;
- }
- }
-
- entry = &tPtr->entry[0];
- aVar =
- (AVariablePtr)
- addOffset(theLink+1,(argumentCount+resultCount) * sizeof(AVariable));
- /* aVar now points to the high addr of the parameters */
-
- for (k = 0; k < tPtr->B.numEntries; k++, entry++)
- if ((entry->TE.SS.Format == ShortStaticF) &&
- (entry->TE.SS.paramInfo != IsNotParam)) {
- /* There are parameters */
- KMDPrint("\tShortStaticF\t(%s) %s\tcount =%4d\n",
- PPBrand(entry->TE.SS.theBrand),
- PPParamInfo(entry->TE.SS.paramInfo), entry->TE.SS.count);
- KMDPrint("%d parameter%s\n", entry->TE.SS.count,
- mPLURAL(entry->TE.SS.count));
- for (i = entry->TE.SS.count; i > 0 ; i--) {
- KMDPrint("%4d: Param #%d (0x%05x, 0x%05x), %s\n",
- byteOffset(l, aVar), i, aVar->myAbConPtr, aVar->myAddr,
- PPVar(aVar));
- aVar--;
- }
- } else break;
- if (IsNULL(theLink->l)) {
- KMDPrint("%4d: DynamicLink, old l: 0x%05x (bottom)\n",
- byteOffset(l, &theLink->l), theLink->l);
- } else {
- KMDPrint("%4d: DynamicLink, old l: 0x%05x (l+%d)\n",
- byteOffset(l, &theLink->l), theLink->l,
- byteOffset(l, theLink->l));
- }
- KMDPrint("%4d: DynamicLink, old g: 0x%05x\n",
- byteOffset(l, &theLink->g), theLink->g);
- KMDPrint("%4d: DynamicLink, old b: 0x%05x\n",
- byteOffset(l, &theLink->b), theLink->b);
- KMDPrint("%4d: DynamicLink, old ip: 0x%05x\n",
- byteOffset(l, &theLink->ip), theLink->ip);
- sAddr = (SSAddr) theLink;
- entry = &tPtr->entry[0];
-
- for (it = 0; it < tPtr->B.numEntries; it++) {
- if (entry->TE.SS.Format == RegisterF) {
- int reg;
- register TemplateEntryPtr t = entry;
-
- KMDPrint("\tRegisterF\t(%s),\t%s, r%d, count %d\n",
- BrandNames[(int)t->TE.R.theBrand],
- t->TE.R.storedWhere==InRegister ? "InRegister":"InSaveArea",
- t->TE.R.reg, t->TE.R.count);
- if (t->TE.R.storedWhere == InSaveArea) {
- for (reg = t->TE.R.count - 1 ; reg >= 0; reg--) {
- /* Registers are stored low number, low addr */
- sAddr--; /* Since we are going backwards */
- KMDPrint("%4d: Saved Register r%d:\t0x%08x\n",
- byteOffset(l, sAddr), t->TE.R.reg+reg, *sAddr);
- }
- } else {
- for (reg = 0; reg < t->TE.R.count; reg++) {
- switch (t->TE.R.theBrand) {
- case DataBrand: {
- KMDPrint("\tIn r%d: Data:\t0x%08x\n",
- t->TE.R.reg+reg,mGetSavedReg(®s, t->TE.R.reg+reg));
- break;
- }
- case ODPBrand: {
- ODP regValue;
- regValue = (ODP) mGetSavedReg(®s, t->TE.R.reg+reg);
- KMDPrint("\tIn r%d: ODP:\t0x%08x\t%s\n",
- t->TE.R.reg+reg, regValue, PPODP(regValue));
- break;
- }
- case VariableBrand: {
- AVariable theVar;
- theVar.myAddr = (DataAddr)
- mGetSavedReg(®s, t->TE.R.reg+reg);
- theVar.myAbConPtr = (AbConPtr)
- mGetSavedReg(®s, t->TE.R.reg+reg+1);
- KMDPrint("\tIn r%d-%d: Var: %s\n",
- t->TE.R.reg+reg, t->TE.R.reg+reg+1, PPVar(&theVar));
- reg++; /* Since vars take 2 registers */
- break;
- }
- default: {
- ErrMsg("Brand %d not allowed in snapData\n", t->TE.R.theBrand);
- KMDPrint("Brand %d not allowed insnapData\n",t->TE.R.theBrand);
- }
-
- } /* end switch (t->TE.R.theBrand) */
- }
- }
- t = (TemplateEntryPtr) addOffset(t, sizeof(t->TE.R));
- entry = t;
-
- continue;
- }
-
- assert(entry->TE.SS.Format == ShortStaticF);
- if (entry->TE.SS.paramInfo != IsNotParam) {
- KMDTrace("FixMe", 5,
- "Portability: entry++ might not add right amount\n");
- entry++;
- continue;
- }
-
- KMDPrint("\tShortStaticF\t(%s)\tcount =%4d\n",
- BrandNames[(int)entry->TE.SS.theBrand], entry->TE.SS.count);
-
- switch (entry->TE.SS.theBrand) {
- case DataBrand: {
- register int j;
- int intCount;
- assert (entry->TE.SS.count % sizeof(int) == 0);
- intCount = entry->TE.SS.count/sizeof(int);
- for (j = intCount; j > 0; j--) {
- sAddr--;
- KMDPrint("%4d: Data: \t0x%08x\n", byteOffset(l, sAddr), *sAddr);
- }
- break;
- }
-
- case ODPBrand: {
- register int j;
- register ODP *theODPPtr;
- theODPPtr = (ODP *) sAddr;
- for (j = 1; j <= entry->TE.SS.count; j++) {
- theODPPtr--;
- KMDPrint("%4d: ODP \t(0x%05x)\n",
- byteOffset(l, theODPPtr), * ((int *) theODPPtr));
- }
- sAddr = (SSAddr) theODPPtr;
- break;
- }
-
- case AddrBrand:{
- sAddr -= entry->TE.SS.count;
- KMDPrint("%4d: Address \t(0x%05x) count %d\n",
- *(int *)sAddr, entry->TE.SS.count);
- break;
- }
-
- case VectorBrand: {
- KMDPrint("Vector (in SS ??) ElementBrand = %s\n",
- BrandNames[(int)entry->TE.SS.elementBrand]);
- assert(entry->TE.SS.theBrand != VectorBrand);
- break;
- }
-
- case VariableBrand: {
- register int j;
- register AVariablePtr varPtr;
-
- for (j = 1; j <= entry->TE.SS.count; j++){
- sAddr = (SSAddr) addOffset(sAddr, -sizeof(AVariable));
- varPtr = (AVariablePtr) sAddr;
- KMDPrint("%4d: Variable\t(0x%04x, 0x%04x), %s\n",
- byteOffset(l, sAddr),
- varPtr->myAddr, varPtr->myAbConPtr,
- PPVar(varPtr));
- }
- break;
- }
-
- case MonitorBrand: {
- register MonitorLockPtr mPtr;
- register SSPtr ptr;
-
- sAddr = (SSAddr) addOffset(sAddr, sizeof(MonitorLock));
- mPtr = (MonitorLockPtr) sAddr;
- KMDPrint(" *** Monitor in Activation record !!??\n");
- KMDPrint("%4d: Monitor %s\n",
- byteOffset(l, sAddr), mPtr->isLocked ? "Locked" : "Open");
- if (NonNULL(mPtr->waiting)) {
- KMDPrint(" Awaiting entry:\n");
- ptr = getRQLink(mPtr->waiting);
- do {
- KMDPrint(" 0x%04x\n", ptr->processOID);
- ptr = getRQLink(ptr);
- } while (ptr != mPtr->waiting);
- }
- break;
- }
-
- case InvokeQueueBrand: {
- sAddr = (SSAddr) addOffset(sAddr, -sizeof(InvokeQueue));
- if (*(sAddr+2) < 0) {
- KMDPrint("%4d: InvokeQueue\t(0x%05x, 0x%05x) *(0x%05x)\n",
- byteOffset(l, sAddr), *sAddr, *(sAddr+1), -(*(sAddr+2)));
- } else {
- KMDPrint("%4d: InvokeQueue\t(0x%05x, 0x%05x) (0x%05x)\n",
- byteOffset(l, sAddr), *sAddr, *(sAddr+1), (*(sAddr+2)));
- }
- break;
- }
-
- default: {
- KMDPrint("Bad brand %s in snapData\n",
- PPBrand(entry->TE.SS.theBrand));
- assert(FALSE);
- }
-
- } /* end switch (entry->TE.SS.theBrand) */
-
- entry = (TemplateEntryPtr) addOffset(entry, sizeof(ShortStatic));
- }
-
- /* The rest is assumed to be variables */
- {
- register AVariablePtr varPtr;
- varPtr = (AVariablePtr) sAddr;
- varPtr --;
- while (SSValidAddr(p, (SSAddr) varPtr) && ( (SSAddr) varPtr >= sp)) {
- KMDPrint("%4d: Variable (0x%04x, 0x%04x), %s\n",
- byteOffset(l, varPtr),
- varPtr->myAddr, varPtr->myAbConPtr, PPVar(varPtr));
- varPtr--;
- }
- }
- KMDPrint("\n********** End of activation record *********\n");
-
- /* Now move on to the next activation record */
-
- /* Restore registers from register save area */
-
- entry = &tPtr->entry[0];
- sAddr = (SSAddr) theLink;
- for (i = 0; i < tPtr->B.numEntries; i++) {
-
- switch (entry->TE.SS.Format) {
-
- case ShortStaticF: {
- KMDPrint("\tShortStaticF\t(%s) %s\tcount =%4d\n",
- BrandNames[(int)entry->TE.SS.theBrand],
- entry->TE.SS.paramInfo != 0 ? "isParam" : " ",
- entry->TE.SS.count);
-
- switch (entry->TE.SS.theBrand) {
-
- case DataBrand: {
- sAddr = (SSAddr) addOffset(sAddr, -entry->TE.SS.count);
- break;
- }
-
- case ODPBrand: {
- sAddr = (SSAddr) addOffset(sAddr, -sizeof(ODP)*entry->TE.SS.count);
- break;
- }
-
- case AddrBrand:{
- assert(entry->TE.SS.theBrand != AddrBrand);
- break;
- }
-
- case VectorBrand: {
- break;
- } /* case Vector Brand */
-
- case VariableBrand: {
- sAddr = (SSAddr)
- addOffset(sAddr, -sizeof(AVariable)*entry->TE.SS.count);
- break;
- }
-
- case MonitorBrand: {
- sAddr = (SSAddr) addOffset(sAddr, -sizeof(MonitorLock));
- break;
- }
-
- case InvokeQueueBrand: {
- sAddr = (SSAddr) addOffset(sAddr, -sizeof(InvokeQueue));
- break;
- }
-
- default: {
- ErrMsg("Bad brand %s in snapData (ARend)\n",
- PPBrand(entry->TE.SS.theBrand));
- break;
- }
-
- } /* end switch (entry->TE.SS.theBrand) */
-
- entry = (TemplateEntryPtr) addOffset(entry, sizeof(ShortStatic));
- break;
- }
-
- case RegisterF: {
- KMDPrint("\tRegisterF\t(%s),\t%s, r%d, count %d\n",
- BrandNames[(int)entry->TE.R.theBrand],
- entry->TE.R.storedWhere == InRegister ? "InRegister"
- : "InSaveArea", entry->TE.R.reg, entry->TE.R.count);
- if (entry->TE.R.storedWhere == InSaveArea) {
- for (k = entry->TE.R.count - 1 ; k >= 0; k--) {
- /* Registers are stored low number, low addr */
- sAddr--; /* Since we are going backwards, do -- first */
- KMDPrint("Restoring r%d, was 0x%02x, now 0x%02x\n",
- entry->TE.R.reg+k,
- mGetSavedReg(®s, entry->TE.R.reg+k),
- *sAddr);
- mSetSavedReg(®s, entry->TE.R.reg+k, *sAddr);
- }
- }
- entry = (TemplateEntryPtr) addOffset(entry, sizeof(entry->TE.R));
- break;
- } /* case RegisterF */
-
- default: {
- KMDPrint("Bad format 0x%02x\n", entry->TE.SS.Format);
- abort();
- break;
- } /* default action */
-
- } /* switch on entry->TE.SS.Format */
- } /* for (i = 0; ...) */
-
- ip = theLink->ip;
- b = theLink->b;
- g = theLink->g;
- l = theLink->l;
- sp = (SSAddr) (theLink+1);
- theLink = mDynLinkPtrFromL(l);
- } /* while there are more ARs */
-
- /* Now print the Requests */
- break;
- }
-
- case CodeODTag: {
- register CodePtr cPtr;
- StringPtr cName;
- cPtr = fEntry->C.dataPtr;
- if (IsNULL(cPtr)) {
- KMDPrint("Non-resident Code OID %s\n", PPCOID(fEntry->C.ownOID));
- break;
- }
- /* Note, the following should use PPCodePtr */
- cName = (StringPtr) addOffset(cPtr, cPtr->codeNameOffset);
- KMDPrint("Resident Code (0x%06x) OID 0x%04x\t\t%.*s\n", cPtr,
- cPtr->ownOID, cName->sizeInBytes, &cName->data[0]);
- break;
- }
-
- case AbConTag: {
- register AbConPtr ab;
-
- ab = (AbConPtr) fEntry;
- KMDPrint("AbCon (%s, %s)\n", PPCOID(ab->ATOID), PPCOID(ab->CodeOID));
- if (NonNIL(ab->restrictOID)) {
- KMDPrint("Restricted to %s\n", PPCOID(ab->restrictOID));
- } else {
- KMDPrint("Not restricted\n");
- }
-
- break;
- }
-
- case CodeTag: {
- register CodePtr c;
- c = (CodePtr) fEntry;
- KMDPrint("Code data area: %s\n", PPCodePtr(c));
- break;
- }
-
- case CondTag: {
- register CondODP cd;
- register SSPtr p;
-
- cd = (CondODP) fEntry;
- KMDPrint("Condition (0x%06x) tied to lock at 0x%05x\n", cd,
- cd->theLock);
- KMDPrint("OwnOID: %s\n", PPOID(cd->ownOID));
- if (NonNULL(cd->waiting)) {
- p = cd->waiting;
- do {
- p = getRQLink(cd->waiting);
- KMDPrint("\tWaiting process \t%s\n", PPPOID(p->processOID));
- } while (p != cd->waiting);
- }
- break;
- }
-
- case DotoTag: {
- KMDPrint("DotoFile contains:\n");
- snapData((ODP)
- dotoCodePtr((DotoFilePtr) addOffset(fEntry, sizeof(ODTag))));
- break;
- }
-
- default:
- KMDPrint("Unknown Tag %s\n", PPODTag(fEntry->G.tag));
- break;
- }
- }
-
- /* Snapshot */
- void OTDataDump(fIndex)
- int fIndex;
- /* Snapshot to dump an OT entry or the entire OT (in hash order) */
- {
- register int index;
- time_t theTime = time((time_t *) 0);
-
- KMDPrint("Object Table dump on node %d %s\n", GetLNN(),
- ctime(&theTime));
-
- ps();
-
- if (IsNULL(fIndex)) {
- for (index = 0; index < OTSize; index++) {
- if (NonNULL(OT[index])) snapData(OT[index]);
- }
- } else {
- /* Dump the given OID */
- ODP theODP = OTLookup((OID) fIndex);
- if (NonNULL(theODP)) {
- snapData(theODP);
- } else {
- KMDPrint("OID 0x%04x is not in the Object Table\n", fIndex);
- }
- }
- }
- /*
- * snapCTData
- *
- * Prints CTs that the kernel has. Called from snapshot operations.
- */
- void snapCTData(fEntry)
- ODP fEntry;
- {
- switch (fEntry->G.tag.tag) {
-
- case GODTag:
- case LOTag:
- case GODataTag:
- case SSODTag:
- case SSTag: {
- break;
- };
-
- case CodeODTag: {
- register CodePtr cPtr;
- cPtr = fEntry->C.dataPtr;
- if (IsNULL(cPtr)) {
- KMDPrint("Non-resident Code OID %s\n", PPCOID(fEntry->C.ownOID));
- break;
- }
- KMDPrint("Resident Code OID %s\t\t%.*s\n", PPCOID(cPtr->ownOID));
- break;
- }
-
- case AbConTag: {
- register AbConPtr ab;
-
- ab = (AbConPtr) fEntry;
- KMDPrint("AT Code OID\t%s\nCT Code OID\t%s\n", PPCOID(ab->ATOID),
- PPCOID(ab->CodeOID));
- if (NonNIL(ab->restrictOID)) {
- KMDPrint("Restrict Code OID\t%s\n", PPCOID(ab->restrictOID));
- };
-
- break;
- }
-
- case CodeTag: {
- break;
- }
-
- case CondTag: {
- break;
- }
-
- case DotoTag: {
- snapCTData((ODP)
- dotoCodePtr((DotoFilePtr) addOffset(fEntry, sizeof(ODTag))));
- break;
- }
-
- default:
- KMDPrint("Unknown Tag %s\n", PPODTag(fEntry->G.tag));
- break;
- }
- }
-
- /**********************************************************************/
- /* Declarations for EmDataDump and EmDatumDump */
- /**********************************************************************/
- int count[(int) LastODBasicTag];
- double sumOfSize[(int) LastODBasicTag];
-
- /**********************************************************************/
- /* EmDatumDump */
- /**********************************************************************/
-
- void EmDatumDump(fAddr, fSize)
- ODP fAddr;
- unsigned int fSize;
- {
- extern int KMDSnapSock;
- /*
- * The following is a hack to make the kernel get done faster when the
- * user kills the dump prematurely. Performance optimizaiton: It can
- * safely be removed.
- */
- if (KMDSnapSock == NULL) return;
-
- KMDPrint("\n**** 0x%06x **** size: %4d bytes ********************\n",
- fAddr, fSize);
- count[(int) fAddr->G.tag.tag]++;
- sumOfSize[(int) fAddr->G.tag.tag] += (double) fSize;
- snapData(fAddr);
- }
-
- /**********************************************************************/
- /* EmCTDatumDump */
- /**********************************************************************/
-
- void EmCTDatumDump(fAddr, fSize)
- ODP fAddr;
- unsigned int fSize;
- {
- extern int KMDSnapSock;
- /*
- * The following is a hack to make the kernel get done faster when the
- * user kills the dump prematurely. Performance optimizaiton: It can
- * safely be removed.
- */
- if (KMDSnapSock == NULL) return;
-
- snapCTData(fAddr);
- }
-
- /**********************************************************************/
- /* EmDataDump */
- /**********************************************************************/
- /* Snapshot */
- void EmDataDump()
- /* Dumps the Emerald allocated data areas */
- {
- time_t theTime = time((time_t *) 0);
- int i;
- double sum = 0.0;
- int total = 0;
-
- for (i = 0; i < (int) LastODBasicTag; i++) {
- count[i] = 0;
- sumOfSize[i] = 0.0;
- }
-
- KMDPrint("Emerald data area dump on node #%d at %s", GetLNN(),
- ctime(&theTime));
- EmallocForEach(EmDatumDump);
- KMDPrint("******** Emerald data area stats ********\n");
- KMDPrint("Tag\t\tCount\tSumOfSize\tAvg.size\n");
- for (i = 0; i < (int) LastODBasicTag; i++) {
- if (count[i] == 0) continue;
- KMDPrint("%-12.12s\t%4d\t%10.0f\t%10.2f\n",
- PPODBasicTag((ODBasicTag) i), count[i], sumOfSize[i],
- sumOfSize[i]/((count[i]>0) ? (double) count[i] : 1.0));
- total += count[i];
- sum += sumOfSize[i];
- }
- if (total)
- KMDPrint("Total\t\t%4d\t%10.0f\t%10.2f\n", total, sum, sum/total);
- KMDPrint("******** Emerald data area dump done ********\n");
- }
-
- /**********************************************************************/
- /* EmCTRefDump */
- /**********************************************************************/
- /* Snapshot */
- void EmCTRefDump()
- /* Dumps the Emerald allocated data areas */
- {
- time_t theTime = time((time_t *) 0);
- int i;
- KMDPrint("Emerald CT dump on node #%d at %s", GetLNN(),
- ctime(&theTime));
- EmallocForEach(EmCTDatumDump);
- }
-
- /**********************************************************************/
- /* Template */
- /**********************************************************************/
- TemplatePtr FindTemplate(fCodePtr, fIP)
- CodePtr fCodePtr;
- Offset fIP;
- {
- IPMapPtr templateMap;
- Offset tOffset;
-
- assert(fCodePtr->templateMapOffset != 0);
- templateMap = (IPMapPtr) addOffset(fCodePtr, fCodePtr->templateMapOffset);
- tOffset = IPMapLookup(templateMap, byteOffset(fCodePtr, fIP));
- assert(tOffset != (Offset) 0);
- return (TemplatePtr) addOffset(fCodePtr, tOffset);
- }
-
- int FindVectorSize(fVectorPtr)
- VectorPtr fVectorPtr;
- /* Find the size of a vector */
- {
- CodePtr cp;
- TemplatePtr template;
- register TemplateEntryPtr t;
- register int i;
- Bytes *dataAddr;
-
- /* Must dig size out of template */
- cp = fVectorPtr->myCodePtr;
- template = (TemplatePtr) addOffset(cp, cp->ODATemplateOffset);
- t = (TemplateEntryPtr) &template->entry[0];
- if (cp->instanceTag.replicated) {
- dataAddr = (Bytes *) &(((ODP) fVectorPtr)->R.inlineData[0]);
- } else {
- dataAddr = (Bytes *) &(((ODP) fVectorPtr) ->L.inlineData[0]);
- }
-
- for (i = template->B.numEntries; i > 0; i--) {
- switch (t->TE.SS.Format) {
- case ShortStaticF: {
- KMDTrace("Vector", 5,
- "\tShortStaticF\t(%s) %s\tcount =%4d\n",
- PPBrand(t->TE.SS.theBrand),
- t->TE.SS.paramInfo != 0 ? "isParam" : " ",
- t->TE.SS.count);
-
- switch (t->TE.SS.theBrand) {
-
- case DataBrand: {
- register int j;
- for (j = 0; j < t->TE.SS.count; j+=sizeof(int)) {
- KMDTrace("Vector", 5, "%6d: Data: %08x\n",
- (dataAddr + j) - (Bytes *) fVectorPtr,
- * ((int *)(dataAddr + j)));
- }
- /* HACK: compiler generates a count of one instead of four */
- dataAddr += (t->TE.SS.count == 1 ? 4 : t->TE.SS.count);
- break;
- }
-
- case ODPBrand: {
- register int j;
- for (j = 1; j <= t->TE.SS.count; j++) {
- KMDTrace("Vector", 5, "%6d: ODP (0x%05x)\n",
- dataAddr - (Bytes *) fVectorPtr,
- * ((int *) dataAddr));
- }
- dataAddr += sizeof(ODP) * t->TE.SS.count;
- break;
- }
-
- case AddrBrand:{
- assert(t->TE.SS.theBrand != AddrBrand);
- dataAddr += t->TE.SS.count * sizeof(dataAddr);
- break;
- }
-
- case VectorBrand: {
- register VectorAreaPtr v;
- register int lcount;
-
- v = (VectorAreaPtr) dataAddr;
- dataAddr = (Bytes *) &v->data[0];
- lcount = v->count;
-
- KMDTrace("Vector", 5,
- "\t\tElementBrand = %s, count %d\n",
- BrandNames[(int)t->TE.SS.elementBrand], lcount);
- KMDTrace("Vector", 5, "\t\tVector type %s\n",
- PPCOID(fVectorPtr->myCodePtr->ownOID));
-
- switch (t->TE.SS.elementBrand) {
-
- case DataBrand: {
- if (fVectorPtr->myCodePtr->ownOID
- == (unsigned int) 0xff00008b) {
- /* A real hack but for debug only */
- /* It is a string */
- KMDTrace("Vector", 5, "\t\tString: %.*s\n", lcount,
- &v->data[0]);
- } else KMDTrace("Vector", 5, "\t\tVector is data.\n");
- dataAddr += lcount;
- break;
- }
-
- case ODPBrand: {
- register ODP *ODPAddr = (ODP *) dataAddr;
- register int j;
- for (j = 0; j < lcount / sizeof(ODP); j++) {
- KMDTrace("Vector", 5,
- "\t\t%6d: %s %s\n",
- j, PPODP(*ODPAddr),
- t->TE.SS.attachedFlag ? " Attached" : "");
- ODPAddr++;
- }
- dataAddr += lcount;
- break;
- }
-
- case VariableBrand: {
- register int j;
- register AVariablePtr varPtr;
-
- for (j = 0; j < lcount / sizeof(AVariable); j++){
- varPtr = (AVariablePtr) dataAddr;
- if (IsNIL(varPtr->myAddr) ||
- IsNIL(varPtr->myAbConPtr))
- {
- KMDTrace("Vector", 5, "\t\t%6d: Var (NIL, NIL)\n", j);
- continue;
- }
- KMDTrace("Vector", 5,
- "\t\t%6d: Var (0x%01x, 0x%01x), %s\n", j,
- varPtr->myAddr, varPtr->myAbConPtr,
- PPVar(varPtr));
- }
- dataAddr += lcount;
- break;
- }
-
- default: {
- ErrMsg(
- "Bad element brand %s, in vector -- compiler error\n",
- PPBrand(t->TE.SS.elementBrand));
- abort();
- }
-
- } /* switch on Vector element brand*/
-
- break;
- } /* case Vector Brand */
-
- case VariableBrand: {
- register int j;
- register AVariablePtr varPtr;
-
- for (j = 1; j <= t->TE.SS.count; j++){
- varPtr = (AVariablePtr) dataAddr;
- KMDTrace("Vector", 5, "%6d: Variable (0x%04x, 0x%04x), %s\n",
- dataAddr - (Bytes *)fVectorPtr,
- varPtr->myAddr, varPtr->myAbConPtr,
- PPVar(varPtr));
- dataAddr += sizeof(AVariable);
- }
- break;
- }
-
- case MonitorBrand: {
- register MonitorLockPtr mPtr;
- register SSPtr p;
-
- mPtr = (MonitorLockPtr) dataAddr;
- KMDTrace("Vector", 5, "%6d: Monitor %s\n",
- dataAddr - (Bytes *) fVectorPtr,
- mPtr->isLocked ? "Locked" : "Open");
- /* for the following assert search for comments re
- * MONITOROFFSETWITHINOBJECT
- */
- assert(MONITOROFFSETWITHINOBJECT == byteOffset(fVectorPtr, dataAddr));
- if (NonNULL(mPtr->waiting)) {
- KMDTrace("Vector", 5, "\tAwaiting entry:\n");
- p = getRQLink(mPtr->waiting);
- do {
- KMDTrace("Vector", 5, "\t\t%s in %s\n",
- PPPOID(p->processOID), PPSSPlace(p));
- p = getRQLink(p);
- } while (p != mPtr->waiting);
- }
- dataAddr += sizeof(MonitorLock);
- break;
- }
-
- default: {
- KMDTrace("Vector", 5, "Bad brand %s in FindVectorSize\n",
- PPBrand(t->TE.SS.theBrand));
- }
-
- } /* end switch */
-
- t = (TemplateEntryPtr) addOffset(t, sizeof(ShortStatic));
- break;
- }
-
- case RegisterF:
- KMDTrace("Vector", 5, "\tRegisterF\t(%s),\t%s, r%d, count %d\n",
- BrandNames[(int)t->TE.R.theBrand],
- t->TE.R.storedWhere == InRegister ? "InRegister"
- : "InSaveArea", t->TE.R.reg, t->TE.R.count);
- KMDTrace("Vector", 5,
- "Compiler Error (?): registers in data area ???\n");
- break;
-
- default:
- ErrMsg("Bad format %d\n", t->TE.SS.Format);
- abort();
- break;
- }
- }
- i = (int) (byteOffset(fVectorPtr, dataAddr));
- KMDTrace("Vector", 4, "Size returned is %d\n", i);
- return i;
- }
-
- /* Copyright 1986 Eric Jul */
-